jquery ajax函数

来源:互联网 发布:男士衣服品牌 知乎 编辑:程序博客网 时间:2024/06/10 16:16
function loading(url,data,loadingText,func){
    $.ajax({
        type:'POST',
        url:url,
        data:data,
        //dataType:'json',
        success:function(msg){
            $('#loading').html(msg);
            if ('function' == typeof func) func();
        },
        error:function(XMLHttpRequest, textStatus, errorThrown){
            $('#loading').html('出错了,错误为:'+textStatus+','+errorThrown+'<br />三秒后自动刷新页面');
            setTimeout('location.reload()',3000);
        }
    })

}


loading('sync/sites',{seoOnly:true},'正在同步,请耐心等待...',function(){setTimeout('location.reload()',5000)});


原创粉丝点击