2011-05-23 66 views
2

我正在调用.net xml webservice。即时通信的网络方法是“validatePassword” 我不知道我在这里做错了什么。我仍然非常新的jQuery和Ajax。jquery.ajax readystate 0,状态0

var name = $("#name",$("#loginPage")).val(); 
    var password = $("#password",$("#loginPage")).val(); 
    var ServiceUrl = "http://localhost:52146/SmartMeterMobile_WebService/User.asmx";  
    var soapEnv ="<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>\ 
         <soapenv:Body> \ 
         <validatePassword xmlns='http://tempuri.org/'>\ 
       <UserName>"+name+"</UserName>\ 
       <Password>"+password+"</Password>\ 
      </validatePassword>\ 
      </soapenv:Body> \ 
       </soapenv:Envelope>"; 

      $.ajax({ 
       url: ServiceUrl, 
       type: "POST", 
       dataType: "xml", 
       data: soapEnv, 
       complete: processResult, 
       contentType: "text/xml; charset=\"utf-8\"" 
      }); 


function processResult(xData, status) { 

      $(xData.responseXML).find("NewDataSet").each(function() { 
       alert($(this).find("intUserIdUS")) 
      }); 
     } 

xml response。

<?xml version="1.0" encoding="utf-8"?> 
<DataSet xmlns="http://tempuri.org/"> 
    <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> 
    <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true"> 
     <xs:complexType> 
     <xs:choice minOccurs="0" maxOccurs="unbounded"> 
      <xs:element name="tblData"> 
      <xs:complexType> 
       <xs:sequence> 
       <xs:element name="intUserIdUS" type="xs:int" minOccurs="0" /> 
       </xs:sequence> 
      </xs:complexType> 
      </xs:element> 
     </xs:choice> 
     </xs:complexType> 
    </xs:element> 
    </xs:schema> 
    <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"> 
    <NewDataSet xmlns=""> 
     <tblData diffgr:id="tblData1" msdata:rowOrder="0"> 
     <intUserIdUS>1</intUserIdUS> 
     </tblData> 
    </NewDataSet> 
    </diffgr:diffgram> 
</DataSet> 
+0

没有人有什么想法? – root 2011-05-24 02:18:36

+0

怎么回事?你看到警报吗?如果你做它说什么?给我们一些更多的信息,这将有助于给出准确的答案! – 2011-05-25 22:28:35

+0

不,我没有看到任何警报。我用萤火虫来检查http请求是否经过,但它给了我一个405方法不允许 – root 2011-05-26 23:05:33

回答

0

您的XML属性具有单引号而不是双引号。

错误

<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> 
相关问题