javascript - I think beforeSend function works incorrectly on chrome -
when send "async=false" request using ajax, possible show loading sign duration of response. , yes, alert message appears i've never seen loading sign.
by way, there no problem firefox. works in chrome when change async value true.
any idea?
var httputil = { : function(url, onsuccess, onfailure) { this.ajaxcall('get', url, this.defaultcontenttype, null, false, false, onsuccess, onfailure); }, post : function(url, request, onsuccess, onfailure) { var showsuccessmsg = url.indexof('/filter') < 0; this.ajaxcall('post', url, null, json.stringify(request), showsuccessmsg, true, onsuccess, onfailure); }, postformdata : function(url, request, onsuccess, onfailure) { this.ajaxcall('post', url, false, request, true, true, onsuccess, onfailure); }, put : function(url, request, onsuccess, onfailure) { this.ajaxcall('put', url, null, json.stringify(request), true, true, onsuccess, onfailure); }, delete : function(url, onsuccess, onfailure) { this.ajaxcall('post', url, null, null, true, true, onsuccess, onfailure); }, ajaxcall : function(type, url, contenttype, request, showsuccessmsg, showloading, onsuccess, onfailure) { if(contenttype == null){ contenttype = 'application/json'; } $.ajax({ url: url, type: type, data: request, async: false, contenttype : contenttype, processdata : false, success: function(data) { if(showsuccessmsg){ showmessage.success("success!", function onconfirm(){ onsuccess(data); }); }else{ onsuccess(data); } }, error: function(error) { if (onfailure instanceof function) { onfailure(error); } else { if(error.responsejson){ showmessage.error(error.responsejson.status, error.responsejson.message); }else{ showmessage.error(json.stringify(error)); } } }, beforesend : function() { if(showloading){ //$('.loading1').css("z-index","11111"); $('.loading1').css("display","block"); //alert("1"); } }, complete : function() { if(showloading){ //$('.loading1').css("z-index","-1"); $('.loading1').css("display","none"); } } }); } };
try :
try adding delay of 1 ms in before send :
beforesend : function() { if(showloading){ //$('.loading1').css("z-index","11111"); settimeout(function(){ $('.loading1').css("display","block"); }, 1); //alert("1"); } },
Comments
Post a Comment