从AJAX调用web服务在Internet Explorer中不起作用
我有一段调用web服务的代码,当我在Firefox或Chrome中使用它时,它可以正常工作,但当我在InternetExplorer中使用它时,它却无法工作 这是我的密码从AJAX调用web服务在Internet Explorer中不起作用,ajax,web-services,Ajax,Web Services,我有一段调用web服务的代码,当我在Firefox或Chrome中使用它时,它可以正常工作,但当我在InternetExplorer中使用它时,它却无法工作 这是我的密码 <html> <head> <title>Parsing XML Test</title> <style> body { padding: 0; margin: 0; } html, body, #map {
<html>
<head>
<title>Parsing XML Test</title>
<style>
body {
padding: 0;
margin: 0;
}
html, body, #map {
height: 100%;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>
function initialize() {
var query = 'service_url';
$.ajax({
type: "GET",
url: query,
dataType: 'xml',
success: function (data) {
alert("OK")
},
error: function (response, textStatus, errorThrown) {
alert(errorThrown);
}
});
}
</script>
</head>
<body onload="initialize()">
<div id="map"></div>
</body>
</html>
有人能帮我更正代码吗
提前非常感谢
塞萨尔我用这种方式解决了
<html>
<head>
<title>Parsing XML Test</title>
<style>
body {
padding: 0;
margin: 0;
}
html, body, #map {
height: 100%;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>
function initialize() {
var browser = navigator.userAgent.toLowerCase();
var isIE = (browser.indexOf("msie")>-1 || browser.indexOf("trident")>-1);
if (isIE && window.XDomainRequest) {
if (window.XDomainRequest) {
var query = 'service_url';
var xdr = new XDomainRequest();
if (xdr) {
xdr.onload = function () {
alert("OK");
alert(xdr.responseText);
}
xdr.onerror = function () {
alert("KO");
}
xdr.open('GET', query);
xdr.send();
}
}
}
else {
var query = var query = 'service_url';
$.ajax({
type: "GET",
url: query,
dataType: "text",
crossDomain: true,
success: function (data) {
alert("OK");
alert(data);
},
error: function (response, textStatus, errorThrown) {
alert("KO");
alert(errorThrown);
}
});
}
}
</script>
</head>
<body onload="initialize()">
<div id="map"></div>
</body>
现在它可以在所有浏览器上运行了
我希望这会有用