js调用web service
function requestbyget(data)
{
var xmlHttp;
function CreateXMLHttpRequest() {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
var URL = "http://localhost:47466/WebService1.asmx?op=HelloWorld";
xmlHttp.Open("Get", URL, false); 这里报错“Cannot read property 'Open' of undefined”
xmlHttp.SetRequestHeader("Context-type", "text/xml;charset=utf-8");
xmlHttp.SetRequestHeader("SOAPAction", "http://tempuri.org/SayHelloTo");
xmlHttp.Send(data);
var request = xmlHttp.status;
if (request == 200) {
document.write(xmlHttp.responseText);
}
xmlHttp = null;
}