最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jquery - javascript not working on localhost - Stack Overflow

programmeradmin3浏览0评论

Ok so I'm lost here, frustrated and pulling my hair and out. Plus probably about to be fired or take a pay cut.

I moved Files from a development server to my local machine. The files are consistent (used diff tool), all the dependencies are there. It works for the most part. The problem is that the some of the javascript (not all) is just not working. We're using jquery and a lot of plugins for it. I've checked with the web developer plugin in firefox and all the js files are loading. I cleared the cache in both firefox and chrome multiple times to no avail. The development server is a windows server running wamp. My local machine is running ubuntu. Somebody tell me what I missed.

Ok so I'm lost here, frustrated and pulling my hair and out. Plus probably about to be fired or take a pay cut.

I moved Files from a development server to my local machine. The files are consistent (used diff tool), all the dependencies are there. It works for the most part. The problem is that the some of the javascript (not all) is just not working. We're using jquery and a lot of plugins for it. I've checked with the web developer plugin in firefox and all the js files are loading. I cleared the cache in both firefox and chrome multiple times to no avail. The development server is a windows server running wamp. My local machine is running ubuntu. Somebody tell me what I missed.

Share Improve this question asked May 4, 2010 at 22:38 Adam McMahonAdam McMahon 4132 gold badges9 silver badges20 bronze badges 2
  • 1 What's your Error Console give you for error messages? I have you tried the Firefox Firebug add-on to help debug? Can you give us a code sample? – gurun8 Commented May 4, 2010 at 22:43
  • I resolved the issue. I did another run through firebug using the console which I was negligent of and picked some php errors that I hadn't resolved when relocating the files. Thank you all for your prompt responses though :) – Adam McMahon Commented May 4, 2010 at 23:20
Add a ment  | 

5 Answers 5

Reset to default 5

Download firebug as a Firefox extension and view the http request and responses. Easiest may be from within the 'net' tab to determine if your script is making a request.

Very likely that it is a source domain issue. There are no work-around for this issue. The ajax request and the source data must be on the same domain.

It may have something to do with JavaScript's security limitations. (In certain circumstances) You can only operate on URLs or pages from the current domain, which most likely changed when you moved the files off the other server. More here.

Are you running the files via a webserver, or just opening the files directly? If it's the latter, you'll want to set up a server on your local machine for local testing, and serve the files using it. Otherwise, you'll very likely run into the domain restrictions others have mentioned above.

You may need to host the site using a local server. VS IDE has an add-on called live server. You need to set up a workspace in order for it to work. The port used on my machine was 5500.

You need to make sure any dependencies for javascript are running on your server or the javascript will not be executed. These dependencies are listed in the json file.

ex. If you require express, you need to be running node or the javascript won't execute in your web browser.

In the terminal: node app.js

Any dependencies that are not installed and running on the server will not execute.

Are you accessing the html web pages through the webserver and not simply double clicking the file to open it?

Also if you have WebDeveloper toolbar installed the click "Disable", "Disable Javascript" and make sure "All Javascript" isn't ticked.

发布评论

评论列表(0)

  1. 暂无评论