我使用Ajax做跨域使用JSON調用,並且腳本在FF中工作正常,但在ie中,腳本將不會使用結果填充select menu
,即ie它將顯示錯誤,所以我知道腳本肯定工作,並進行跨域調用,任何人都可以告訴我我做錯了什麼?JSON跨域使用AJAX不工作ie即
function xss_ajax(url) {
var script = document.createElement('script');
script.setAttribute('type', 'text/javascript');
script.setAttribute('src', url);
script.setAttribute('id', 'script_id');
script_id = document.getElementById('script_id');
if (script_id) {
document.getElementsByTagName('head')[0].removeChild(script_id);
}
document.getElementsByTagName('head')[0].appendChild(script);
document.getElementById("addrlist").innerHTML = "";
document.getElementById("errlog").innerHTML = "";
}
function callback(data) {
if (typeof data['error'] != "undefined") {
if (window.on_error) {
on_error();
}
if (document.getElementById("errlog")) {
document.getElementById("errlog").innerHTML = "<br>" + data['error'] + "<br>";
} else {
alert(data['error']);
}
} else {
var val = data['address1'] + ", " + data['address2'] + ", " + data['address3'] + ", " + data['address4'] + ", " + data['postcode'];
document.getElementById("addrlist").innerHTML += "<option value='" + val + "'>" + val + "</option>";
}
}
function searchpost() {
var license = '98798797';
var url = "http://mydomin.co.uk/myfile.php?postcode=" + escape(document.getElementById("field1").value) + '&license=' + escape(license);
xss_ajax(url);
}
哪裏有AJAX?請求JSON文件或JS文件的 –
? –
@MihaiIorga:它實際上是一個JSONP請求,所以它是向頭部添加腳本標記的代碼。 – Guffa