js中单点登录使用了如下代码:
getJSON("http://sso.jcloud.com/setCookie?t=sso.ehaoyao.com&callback=?");
由于某种原因,目标服务器停止了服务,导致请求超时,无法执行后续的js,直接导致页面不能加载
jQuery.getJSON( url [, data ] [, success( data, textStatus, jqXHR ) ] )
-
urlType: StringA string containing the URL to which the request is sent.
-
dataType: PlainObjectA plain object or string that is sent to the server with the request.
-
success( data, textStatus, jqXHR )Type: Function()A callback function that is executed if the request succeeds.
If the URL includes the string "callback=?" (or similar, as defined by the server-side API), the request is treated as JSONP instead.
By default, all requests are sent asynchronously (i.e. this is set totrue 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.
getJSON默认是异步的,但是跨域时不支持异步,正是因为我的请求时跨域了的,所以同步请求时被阻塞了,因此出现页面不能加载。
本文探讨了JavaScript中实现单点登录(SSO)时遇到的跨域问题及解决方案。当使用getJSON发起跨域请求时,默认为异步,但在某些情况下会变为同步请求并阻塞页面加载。文章详细解释了这一现象的原因。
903

被折叠的 条评论
为什么被折叠?



