In order to use jQuery, do I have to use the following reference in my html?
<script src=".5/jquery.min.js"></script>
What if my server does not have an internet connection?
In order to use jQuery, do I have to use the following reference in my html?
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
What if my server does not have an internet connection?
Share Improve this question edited May 24, 2013 at 20:46 Matthew Strawbridge 20.6k10 gold badges79 silver badges96 bronze badges asked Feb 23, 2012 at 14:29 george willygeorge willy 1,7138 gold badges22 silver badges26 bronze badges 5 |5 Answers
Reset to default 9Use this code:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">window.jQuery || document.write('<script src="/res/jQuery/jquery-1.7.1.min.js"> \x3C/script>');</script>
This will try to download from the CDN, or otherwise use the local one. You must download the local one first though.
It will not work if you don't have internet connection.
To work locally you should copy jquery.js
to your local directory and give relative path.
<script src="/jquery/1.5/jquery.min.js"></script>
It is not specifically for this case, but I think you should definitely understand how Client-server works. Also, you should understand what is Client-side scripting.
You would then understand that you (your browser) need to be connected to Internet in order to be able to reach the http://ajax.googleapis.com domain.
If you want to work with it locally, without ever reaching Internet, then download jQuery locally, and refer to it in your script tag.
Download the latest jquery file:
http://code.jquery.com/jquery-1.7.1.min.js
And save it to you project. It will now be available locally so you can reference it like this (only an example):
<script src="/path-to-your-jquery-file.js"></script>
It does not matter if your server has or has not connection to internet. Only the browser which tries to access page from said server need connection to internet. Server just needs to be "visible" from this browser in question.
It might be better, if you understood the basics of how internet works, before you start playing in developers.
what if my server does not have an internet connection?
How are you connecting to it if it doesn't have a internet connection? And besides, it's the client which requests that file from the Google CDN, not the server. – Rory McCrossan Commented Feb 23, 2012 at 14:31localhost
, I'd imagine. – Ry- ♦ Commented Feb 23, 2012 at 14:32