Reputation: 9074
Developing ASP.NET application with visual studio 2010
I am new with jquery.
I am trying to include JQuery file online (from google)
For this i have written it as:
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
Here it is highlighting src attribute with green text showing tool tip that:
//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js not found.
If i write it as:
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
It shows me error as a tooptip that:
Element 'script' is missing required attribute 'type'
But this is the actual way in which i refered this line on different sites.
I have refered this addess from different sites.
Is this address is wrong? or
I have written it in wrong way?
please help me.
Upvotes: 0
Views: 1388
Reputation: 70149
Protocol-less paths inherit the protocol of the current document when opened in a browser, so this will work when your page is opened through http
/https
protocols.
Therefore I assume that your VS interprets the protocol-less path as a local one, thus it is not found.
You can check that the CDN URL is correct by opening the link directly through either http/https protocols:
http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js
https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js
As for the type
attribute, see Why write <script type=“text/javascript”>
when the mime type is set by the server?
In sum, all browsers since Netscape 2 default script tags to javascript
, so as long as the server sends the correct MIME it will work just fine. However, it wouldn't validate under W3C's HTML4 mode. In HTML5, it is valid to omit the type
attribute as commented by @elclanrs.
Upvotes: 1
Reputation:
use it like this. it works
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
Upvotes: 1