私はHTML、JavaScriptのみでプロジェクトをやっています。 Webサービス(.asmx)からデータを取得する機能があり、正常に動作しています。しかし、Firefoxでは、Chromeは動作しません。ここでのコードで、確認してください:Mozilla FirefoxでWebサービスデータを取得する方法は?
はfunction CreateXMLHttpRequest()
{
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
return new XMLHttpRequest();
}
else {// code for IE6, IE5
return new ActiveXObject("Microsoft.XMLHTTP");
}
}
function CallWebService() {
var objXMLHttpRequest = CreateXMLHttpRequest();
objXMLHttpRequest.open ("POST",
"http://www.xxxxxxxxx.com/WebServicesp/WebMethods.asmx",
false);
objXMLHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
var packet='<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body></soap:Body></soap:Envelope>';
objXMLHttpRequest.send(packet);
var res=objXMLHttpRequest.responseText;
alert(res);
}
あなたが "動作しない" とはどういう意味ですか?どのようなエラーが出ますか? – j08691
エラーも結果もありません –
Firebugのようなツールを使用して、http応答を見てください。 – epascarello