秦皇岛保障性住房官网,深圳网站营销seo多少费用,简单网站制作步骤,河南省建设厅网站职称网当前位置:我的异常网 操作系统 ajax 跟post 可以设置它是否同步执行ajax 跟post 可以设置它是否同步执行www.myexceptions.net 网友分享于#xff1a;2013-06-13 浏览#xff1a;0次ajax 和post 可以设置它是否同步执行ajax的async设置成false,为什么没效果$.ajax( {async…当前位置:我的异常网» 操作系统 » ajax 跟post 可以设置它是否同步执行ajax 跟post 可以设置它是否同步执行www.myexceptions.net 网友分享于2013-06-13 浏览0次ajax 和post 可以设置它是否同步执行ajax的async设置成false,为什么没效果$.ajax( {async : false,type : POST,dataType : html,url : getURL() sysset/sysmonit/operation!check.action?idlevel.val(),success : function(json) {if(json3){ alert( 等于3就是不让过)return false;}}});alert(谁先);__________________________________________________________________返回的值是3,json3,进入if alert( 等于3就是不让过)这个也执行了紧接的就是return false;按常理说他不应该弹alert(谁先);,但是他弹出了“谁先”。。。求解!!!你在回调函数里return是没有效果的Jquery的同步和异步请求1 异步请求1.1 $.ajax$.ajax({url : your url,data:{name:value},cache : false,async : true,type : POST,dataType : json/xml/html,success : function (result){do something....}});2 同步请求2.1 $.ajax$.ajax({url : your url,data:{name:value},cache : false,async : false,type : POST,dataType : json/xml/html,success : function (result){do something....}});2.2 $.post$.post(your url,{name:value},function(data) {do something...},json/xml/html);最近在测试,发现有些效果不对,最后发现是post的执行顺序问题,所以研究了下,写了以下总结1.post被请求多次,解决方法:连接加入随机数 randMath.random()复制代码$.post(/Control/webControl.ashx?rand Math.random(), { Method: LoginIn, Parems: ps }, function (data, textStatus) {$(#divOver).css(visibility, hidden);switch (data) {case 1:window.location /default.aspx;break;case 0:$(#tips).text(找不到该用户);u.focus();changevcode();errcount;break;case -1:$(#tips).text(用户或密码错误);changevcode();c.val().focus();errcount;break;default:alert(data);}});复制代码2.因为post默认为异步请求,可是有时候我们会发现,本来要求请求马上出现,可是异步会导致后面突然再执行,这样就出问题了所以,我们需要加入$.ajaxSetup({async : false});3.如果需要有些同步有些异步,那么我们应该使用最原始的ajax请求,然后把async设置为false复制代码$.ajax({type : post,url : register/RegisterState,data : test test,async : false,success : function(data){data eval(( data ));aDataSet data;}});复制代码文章评论