ajax同步

ajax一版写法是异步的,同步写法可以用async属性,false同步。true是异步

 

console.log(1) 

$.ajax({
type : 'GET',
url : 'http://wthrcdn.etouch.cn/weather_mini?city=上海',
async: false,
success: function (data) {
console.log(2)
}
});

console.log(3)

控制台会一次打印出1,2,3

如果async: true,会打印出1,3,2

 

目前只研究到ajax,axios有没有这个属性还不清楚,后续研究出会后面更新的。

 

posted @ 2018-12-25 17:36  时光如瑾季微凉  阅读(160)  评论(0编辑  收藏  举报