我遇到了很多困难 - 我似乎是在圈子里 我想要做的是从客户端的javascript将数据发布到Web服务。
在下面的示例中,valFname
,valLname
,valPhone
和valZip
都有有效的字符串值:
function checkOffers(){
// data collection from loaded form...
var postData = "'FirstName':'" + valFname ;
postData +="','LastName':'" + valLname ;
postData +="','PhoneNumber':'" + valPhone ;
postData += "','Zipcode':'" + valZip+"'";
initialize(postData);
}
function initialize(postData) {
//var postMsg = createSoapHeader(msg);
var url = "https://server.company.com:9999/analytics/webservices/webservice.asmx/SamplePriorityOfferList";
request.open("POST", url, false)
request.onreadystatechange = function(){
if(this.readyState===4){
//request is complete. handle it
processData;
}
};
request.send(postData);
}
function processData(){
response = request.responseXML.xml;
alert("Returned Data:" + response);
}
我在checkOffers
事件上调用PageLoad
函数 - 我希望无需单击按钮,链接等即可触发Web服务。
我从请求中获取空值,但应该获取数据。 任何评论,提示或建议都非常感谢。
答案 0 :(得分:0)
这一行:
if(this.readyState===4){
应该是:
if(this.readyState==4){
至少应该让你看到警报。