2015-05-19 3 views
0

Я попытался найти источник для решения проблемы. но не получил решение моей проблемы.Ошибка запроса на мыло JQuery Ajax

У меня есть webservice в нашей локальной сети 113. Мне нужно использовать это на другом сервере. оба находятся в одной сети.

POST /GeoMapsMirror/MapService.asmx HTTP/1.1 
Host: 172.16.1.113 
Content-Type: text/xml; charset=utf-8 
Content-Length: length 
SOAPAction: "http://tempuri.org/SP_GetDiversion_Details" 

<?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> 
    <SP_GetDiversion_Details xmlns="http://tempuri.org/"> 
     <Code>string</Code> 
    </SP_GetDiversion_Details> 
    </soap:Body> 
</soap:Envelope> 

Мой Jquery

var SoapMessageInXML = '<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/">'; 
      SoapMessageInXML = SoapMessageInXML + '<soap:Body>'; 
      SoapMessageInXML = SoapMessageInXML + '<SP_GetDiversion_Details xmlns="http://tempuri.org/">'; 
      SoapMessageInXML = SoapMessageInXML + '<Code>'+userid+'</Code>'; 
      SoapMessageInXML = SoapMessageInXML + '</SP_GetDiversion_Details>'; 
      SoapMessageInXML = SoapMessageInXML + '</soap:Body>'; 
      SoapMessageInXML = SoapMessageInXML + '</soap:Envelope>'; 

      jQuery.support.cors = true; 
      $.support.cors = true; 

      valurl = 'http://172.16.1.113/GeoMapsMirror/MapService.asmx?op=SP_GetDiversion_Details' 
      $.ajax({ 
      type: "POST", 
      data: SoapMessageInXML, 
      url: valurl, 
      cache: false, 
      dataType: "xml", 
      contentType: "text/xml; charset=\"utf-8\"", 
      //contentType: "text/plain", 
      timeout: 50000, 
      success: function(xml) { 
       alert(xml) 
      }, 
      error :function(jqXHR, textStatus, errorThrown) { 
             console.log("error " + textStatus); 
             console.log("incoming Text " + jqXHR.responseText); 
             if(textStatus == 'timeout') 
             {  
              //alert('Failed from timeout');  
              LoadDiversionDtl3() 
             } 
             else 
             { 
              var err = jqXHR.responseText 
              var n=err.indexOf(","); 
              var m=err.indexOf(":"); 
              alert(err.substring(m,n)) 
             } 
          } 
     }); 


<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> 

я получил ошибку как Invalid HTTP код статуса 403

Я уже застрял в течение более чем 2 дня. Пожалуйста, помогите мне решить эту проблему.

+0

'jQuery.support.cors = TRUE;' - Это переопределяет автоматическое определение JQuery в поддержку CORS в браузере. Единственное, что вы можете достичь, это менее полезные ошибки, если браузер не поддерживает CORS. Не делай этого. (Строка после того, где используется '$' вместо jQuery, делает то же самое, удалите это тоже). – Quentin

ответ

0

После нескольких изменений я нашел ответ. Он работает после удаления тега contentType в jquery.

valurl = 'http://172.16.1.113/GeoMapsMirror/MapService.asmx/SP_GetDiversion_Details?code='+userid 
 
      $.ajax({ 
 
      type: "GET", 
 
      url: valurl, 
 
      cache: false, 
 
      dataType: "xml", 
 
      timeout: 50000, 
 
      success: function(xml) { 
 
       document.getElementById('Spcontentdiv').innerHTML = xml.documentElement.textContent; 
 
      }, 
 
      error :function(jqXHR, textStatus, errorThrown) { 
 
             console.log("error " + textStatus); 
 
             console.log("incoming Text " + jqXHR.responseText); 
 
          } 
 
     });

Смежные вопросы