Ajax方法设定同步无效
hqzxzb opened this issue · comments
逻辑需要使用ajax同步方法来控制顺序,但是使用了async : false设定同步,没有起作用,根据翻ajax模块源代码,发现下面一行代码中,并没有真正使用这个参数进行设定,而是写死了为异步。
xhr.open(settings.type, settings.url, true);
根据前面的代码,我修改为了下面:
xhr.open(settings.type, settings.url, settings.async);
已经可以使用同步方法了,但是在Chrome下会报一个警告,不知道是否有影响,请求本身是可以正常返回的:
Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/.