JQuery Ajax call often not working on Safari 6

后端 未结 5 1706
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-10 09:51

My Ajax call is really simple as below:

function ajax(reqUrl, params , callback) {
console.log(\"Request URL \"+reqUrl);
var cond;
cond = $.ajax({
    type:          


        
5条回答
  •  臣服心动
    2020-12-10 10:19

    This seems to be a Safari issue. In this post there is a suggestion to add a beforeSend to your ajax-request.

    In your case:

    cond = $.ajax({
        type: 'post',
        url: reqUrl,
        data: params,
        beforeSend: function (event, files, index, xhr, handler, callBack) {
             $.ajax({
                 async: false,
                 url: 'closeconnection.php' // add path
             });
        },
        error:function(){ alert("some error occurred") },
        success: callback
    });
    

提交回复
热议问题