Question

Why is it that when I remove //code.jquery.com/jquery-1.9.1.js the site runs my AJAX requests. Though when I have it, I cannot access the JQuery UI datePicker?

<head>    
<link rel="stylesheet" type="text/css" href="CSS/custom.css">
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<link href='http://fonts.googleapis.com/css?family=Cabin:400,600' rel='stylesheet'     type='text/css'>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js" type="text/javascript"></script>

<script type="text/javascript" src='js/custom.js'></script> 
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
</head>

Very bizarre - I posted the google api in a certain place that magically made it work. Anyone know why? I reposted by code here: Why did this sequence of Jquery/Google API requests work?

Was it helpful?

Solution

you are using two jquery and jquery ui. You must use one. since .min.js and .js are same. min.js is just the compressed version of .js

Ie the below code is enough:

<head>    
<link rel="stylesheet" type="text/css" href="CSS/nudgeme.css">
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<link href='http://fonts.googleapis.com/css?family=Cabin:400,600' rel='stylesheet'     type='text/css'>
<link rel="stylesheet" type="text/css" href="CSS/nudgeme.css">

<!-- First import jquery -->
<script src="//code.jquery.com/jquery-1.9.1.js"></script>

<!-- Then Jquery library imports -->
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>    
<script type="text/javascript" src='js/nudgeme.js'></script>

<!-- Then Custom script that uses the above libraries-->
<script type="text/javascript" src='js/custom.js'></script> 
</head>

Use custom.js below all other imports. because javascript executed from top to bottom. so for example if your script uses a javascript function(for eg: jquery $) and you write the code above the import of jquery.js it simple won't work.

OTHER TIPS

Ok i did not found <!DOCTYPE html>(so it is not html5) in your code and so i recommend you to mention type="text/javascript" in you script tag

<script type="text/javascript" src="//code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

for reference link

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top