我正在开发phonegap应用程序。我需要通过.net .net服务验证用户。我使用ajax通过javascript.but验证和解析它,因为它总是返回零,所以我一直停留在readystate上。我从网上找到的解决方案中尝试了很多东西,但我做得不对。
这是我的Javascript:
username = 'ksl';
password = 'ksl';
var soapMessage =
'<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> \
<CheckLogin xmlns="http://tempuri.org/"> \
<UserName>' + username + '</UserName> \
<Password>' + password + '</Password> \
</CheckLogin> \
</soap:Body> \
</soap:Envelope>';
$.ajax({
url: validationURL,
type: "POST",
dataType: "xml",
data: soapMessage,
success: validate,
contentType: "text/xml; charset=\"utf-8\"",
error: function(xhr,status,error)
{
alert("state is:" + xhr.readyState);
}
});
return false; 以下是我的webservice回复:
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?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>
<CheckLoginResponse xmlns="http://tempuri.org/">
<CheckLoginResult>string</CheckLoginResult>
</CheckLoginResponse>
</soap:Body>
</soap:Envelope>任何回应都会有帮助。
发布于 2012-04-21 10:39:26
好的。我发现了问题::
1) </soap:Body> \后有空间,所以我把它去掉了。
2)我在html中做了一些修改,效果很好。
谢谢你看了我的问题。
https://stackoverflow.com/questions/10256730
复制相似问题