JSLite / JSLite

与jQuery有着类似的api,让web开发更迅速,下载执行更快、量级更轻,针对现代高级浏览器的JavaScript库。

Home Page:http://jslite.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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/.

@hqzxzb 不会有影响,警告英文的大概意思是不利于用户体验。