Ajax在safari和chrome中不起作用
ajax is not working in safari and chrome
我正在尝试下面的代码。它在firefox中运行良好,但在chrome或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);
}
});
}
我得到以下错误:
Uncaught ReferenceError: $ is not defined .js:28函数)
,这是第28行:
$.ajax({url:"get_last_device.php"}).done(function(last_visitor_id){
我已经复制了jquery从谷歌(http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js)
有谁能提出解决方案吗?非常感谢您的帮助。认为,
请确保在尝试使用jQuery之前(在页面顶部附近)导入了jQuery。
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
相关文章:
- XMLHttpRequest在移动设备上的chrome上不起作用
- ng disabled在chrome中不起作用.按钮在角度上未禁用
- 鼠标输入在 YUI 的 chrome 中不起作用
- Javascript的某些部分在Chrome中不起作用,但在其他浏览器中可以完美工作
- HTML5视频链接在Chrome中不起作用
- jQuery克隆函数在chrome中不起作用
- jQuery place attr src在Chrome中不起作用
- chrome中的onmouseover(下拉选项标记)事件不起作用-php,javascript
- .ajax调用在chrome中不起作用
- Javascript/AAJAX在Opera中不起作用,在FF/IE/Chrome中完美工作
- 正在处理在chrome扩展中不起作用的js
- MediaSource API demo不起作用(Chrome)
- Chrome 中表格的 CSV 导出不起作用 - JavaScript/AngularJS
- $.getJSON 在 Chrome 和 Safari 中不起作用
- OnClick 事件在 Chrome 中不起作用
- getUserMedia 在 Chrome v50.0.2661.86 上不起作用
- dataTransfer.set拖放的数据在chrome中不起作用
- 简单的鼠标悬停在 Chrome 中不起作用
- window.close();在Chrome和Firefox中不起作用
- SoundCloud widget .play() 方法在选项卡在后台时不起作用 (Chrome)