我正在使用 Ajax 确实使用 JSON 进行跨域调用,并且脚本在 FF 中运行良好,但在 ie 中,脚本不会填充select menu
结果,在 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);
}