在使用$.get或者$.post的时候,前面加上

$.ajaxSettings.async = false;

使用完之后再设置为异步

$.ajaxSettings.async = true;

 

而在使用$.ajax的时候

添加async : false,

就可以了