Reputation: 277
I am trying the following code. its working fine in firefox, but its not working in chrome or safari.
if (getCookie("vantage_device_id")==''){
$.ajax({url:"get_last_device.php"}).done(function(last_visitor_id){
deviceID = ++last_visitor_id;
//alert ("device ID " + deviceID);
console.log("creating cookies");
setCookie("vantage_device_id", deviceID , 365);
$.ajax({
url:"save_device.php?deviceID="+deviceID+"&websiteID="+WebsiteID+"&width="+sWidth+"&height="+sHeight,
success:function(datasource){
//alert (datasource);
}
});
$.ajax({
url:"save_session.php?deviceID="+deviceID+"&websiteID="+WebsiteID+"&url="+url,
success:function(filename){
// saving session data for individual pages ///////////////
//alert ("File Name " + filename);
}
});
});
} else {
deviceID = getCookie("vantage_device_id");
//alert ("Cookies already exists...." + deviceID);
$.ajax({
url:"save_session.php?deviceID="+deviceID+"&websiteID="+WebsiteID+"&url="+url,
success:function(filename){
// saving session data for individual pages ///////////////
//alert ("File Name " + filename);
}
});
}
I am getting the following error:
Uncaught ReferenceError: $ is not defined script.js:28 (anonymous function)
and this is line 28 :
$.ajax({url:"get_last_device.php"}).done(function(last_visitor_id){
I have copied the jquery from google (http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js)
can anyone suggest any solution. any help is apriciated.
Regards,
Upvotes: 0
Views: 468
Reputation: 42
Make sure you import jQuery before (near the top of the page) trying to use it.
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Upvotes: 0