在使用JQuery Ajax的JSONP callback方式解决跨域访问问题时,设置$.ajaxSettings.async为false,仍然无法实现同步调用,经查官网发现,JQuery官网已经针对async属性作用效果做了明确说明,不支持dataTypes为jsonp的请求。默认为true。原文如下:
By default, all requests are sent asynchronously (i.e. this is set to true by default). If you need synchronous requests, set this option to false. Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation. Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active.