Quantcast
Viewing all articles
Browse latest Browse all 8

jQuery .Ajax() 方法在IE浏览器返回No Transport

jQuery Ajax 返回No Transport通常是由于跨域调用javascript造成的。

解决方法很简单(测试在jquery.1.8.3.js),  在你的ajax方法之前加

jQuery.support.cors = true;

完整的代码如下

$(document).ready(function() {
    jQuery.support.cors = true;
    $.ajax( {
	url : "http://test.sharepoint/_vti_bin/listdata.svc/test",
	/*data : {
            "phone" : phoneNo
	},*/
	async:true,
	dataType : "json",
	cache : false,
	success : function(data) {
	    alert("f");
	    if(data!=null && data.d!=null && data.d.results!=null){							$(data.d.results).each(function(i) {
	            alert(this);
		});
	    }
	},
	error : function(XMLHttpRequest, textStatus, errorThrown) {
            alert("error: " + errorThrown);
        }
   });
});

Viewing all articles
Browse latest Browse all 8

Trending Articles