Jquery的同步和異步請求操作
1 ,異步請求:
$.ajax({ url : 'your url', data:{name:value}, cache : false, async : true, type : "POST", dataType : 'json/xml/html', success : function (result){ do something.... } }); $.post( 'your url', {name:value}, function(data) { do something... }, 'json/xml/html' );
2,同步請求:async : false
$.ajax({ url : 'your url', data:{name:value}, cache : false, async : false, type : "POST", dataType : 'json/xml/html', success : function (result){ do something.... } });
原文鏈接:Jquery的同步和異步請求操作