javascript
  • ajax
  • jquery
  • jquery-mobile
  • 2013-05-31 75 views 0 likes 
    0

    請告訴我什麼問題的代碼狀態是200好,但無法從Web服務接收記錄(響應)它顯示錯誤null 請幫助我,我嘗試從2天解決它...錯誤代碼jqueryAjax在線webservice

      var webMethod = "http://www.w3schools.com/webservices/tempconvert.asmx/CelsiusToFahrenheit?callback=?"; 
          var soap ='<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>  <CelsiusToFahrenheit xmlns="http://tempuri.org/"> <Celsius>12</Celsius> </CelsiusToFahrenheit> </soap:Body> </soap:Envelope>'; 
          $j.ajax({ 
            type: "POST", 
            url :webMethod, 
            data: soap, 
            dataType :"xml", 
            contentType:"text/xml; charset=\"utf-8\"", 
            cache:false, 
            async: false, 
           error:function(resp) 
           { 
            alert("Error :"+$j.parseXML(resp)); 
           }, 
    
          }).done(function(response){ 
    
            console.log(response); 
            var xmlData =$j(response).find('FahrenheitToCelsiusResult').text(); 
            alert(xmlData); 
           }); 
    
         }); 
    
    +0

    這是控制檯 的結果[11:50:33.228] OPTIONS http://www.w3schools.com/webservices/tempconvert.asmx/CelsiusToFahrenheit [HTTP/1.1 200 OK 472ms] – Hamid

    回答

    0

    在您的代碼狀態爲200的情況下,這意味着請求發送正常並且響應從服務器發送也ok。所以,這沒有問題。

    可能是你什麼讓null作爲響應的問題是

    1. 你傳遞給服務器什麼是錯的(和服務器不能對你的數據進行任何計算)
    2. 服務器的Web服務可能無法正常工作,預期的和爲您提供了空響應
    +0

    當我loa丁html文件它顯示錯誤,但在控制檯顯示[11:50:33.228]選項http://www.w3schools.com/webservices/tempconvert.asmx/CelsiusToFahrenheit [HTTP/1.1 200 OK 472ms] 我需要一些請求的數據,如pasing record abc,它應該重新列出記錄列表 – Hamid

    相關問題