HTML and CSS Reference
In-Depth Information
//ajax.googleapis.com/ajax/libs/jquery/1.7.1/
jquery.min.js
This way, the browser will use whatever protocol the page has been served with for
the request. You can learn more about protocol-relative URLs in the Appendix sec-
tion.
Of course, this means if you are testing locally, and if you view your page on the
browser, the browser will use a URL that looks like file://users/divya/pro-
jects, and hence the browser will attempt to look for a jQuery file using the follow-
ing URL:
file://ajax.googleapis.com/ajax/libs/jquery/
1.7.1/jquery.min.js
This request will definitely fail, as there is no resource locally at that path. Hence, if
you are using protocol-relative URLs, you need to set up a local server to test your
files. This is easily done on a Mac or Unix-based OS by navigating to your project
folder in your shell interface and executing the following command:
python -m SimpleHTTPServer
This will start a server and your project's index.html file will be available on ht-
tp://localhost:8000 .
Tip
If you are on Windows, copy the Mongoose executable (the latest version at the
time of writing was mongoose-3.3.exe ) from code.google.com/p/mon-
goose/ to your project folder and launch it. Your project's index.html will then
be available at http://localhost:8080 .
Search WWH ::




Custom Search