在页面上通过ajax调用接口,在google浏览器中是正常的,在IE8下出现问题,会提示No Transport的提示。
jQuery.support.cors = true; //添加这句老是就不会提示no transport
$.ajax
({
type: "POST",
contentType: "application/x-www-form-urlencoded",
dataType: "html",
url: "http://www.*****.com", //这里是网址
success:function(data){alert(data);},
timeout:30000,
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(errorThrown);
}
});
jquery.support.cors只是对CORS协议的一种实现,具体可以看jQuery的源代码。