JQuery的Ajax调用通常不工作的Safari 6 [英] JQuery Ajax call often not working on Safari 6

查看:1479
本文介绍了JQuery的Ajax调用通常不工作的Safari 6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Ajax调用非常简单,如下:

My Ajax call is really simple as below:

function ajax(reqUrl, params , callback) {
console.log("Request URL "+reqUrl);
var cond;
cond = $.ajax({
    type: 'post',
    url: reqUrl,
    data: params,
    error:function(){ alert("some error occurred") },
    success: callback
});
console.log("Server response "+cond.readyState);
}
   // Call it as 
    var url = "/getResult";
    var params = {};
    params.param1 = "test1";
    params.param2 = "test2";
    ajax(url, params, function(returnCallback) {
        console.log(returnCallback);
        alert("Success");
    });

这是正常工作在大多数情况下。但有时(约1〜3次),它不返回任何回调。

That works fine in most cases. But sometimes (about 1 times in 3) it doesn't return anything to callback.

我发现了很多的问题和答案的在Safari中不工作阿贾克斯,但罚款Chrome和Firefox 。我的问题是 不同于他们,因为它很好的大部分时间(我不是说这不是罚款通常是因为当我刷新我的浏览器,这可能会导致我的Ajax调用工作)。

I found many questions and answers for Not working ajax in Safari but fine in chrome and FireFox. My problem is different from them, because it's fine most of the time (I don't mean it was not fine usually because when I refresh my browser, that may cause my ajax call to work).

我的主要问题是,为什么我的ajax调用有时会失败?我没有得到我的JS控制台的任何错误。在这种情况下,我刷新我的浏览器来获得我的Ajax调用。任何想法?

My main question is why does my ajax call sometimes fail? I don't get any errors on my JS console. When this situation, I refresh my browser to get my ajax call to. Any Ideas?

更新:

我发现有时候我的ajax调用方法没叫出来,因为的console.log(请求URL+ reqUrl); 没有执行。当我不想刷新我的浏览器,我点击我的网页上的链接很多次,产生的结果。将一些晚来执行?

I found that sometimes my ajax call method didn't call out because console.log("Request URL "+reqUrl); did not execute. When I don't want to refresh my browser, I clicked many times on my page's link to produce result. will something late to execute?

推荐答案

最后,我发现错误.. Safari不重装我的JavaScript文件再次甚至禁用缓存。所以,我把我所有的JS code到:

Finally, I found error .. Safari doesn't reload my JavaScript files again even disable Cache. So I put all of my JS code into:

$(document).ready(function(){
 // start load my js functions
 init();
});

重新载入我的JS文件时,我的网页准备。加油!

to reload my JS files when my page was ready. Cheer !

这篇关于JQuery的Ajax调用通常不工作的Safari 6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆