2017-01-31 2 views
1

Ich habe den folgenden Code geschrieben, um die Soap-XML-Antwort mit jquery zu verarbeiten, aber jQuery kann die Antwort nicht lesen. Gibt es einen Syntaxfehler, den ich im folgenden Code gemacht habe? Ich sehe keine Fehler in der Konsole. Gibt es etwas Falsches im Soap Message Format oder in der Art wie ich es lese?JQuery kann keine Soap-Antwort verarbeiten

Ich bin ein bisschen neu zu dieser Art von Implementierung.

<!DOCTYPE html> 
<html> 
<head> 
<script class="jsbin" src="http://code.jquery.com/jquery-1.7.2.min.js">  </script> 
<script> 

    var xml = '<soapenv:Envelope  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://siebel.com/WebService">\ 
    <soapenv:Header/>\ 
    <soapenv:Body>\ 
    <web:UpdateWO_Input>\ 
    <web:Comments>?</web:Comments>\ 
    <web:WOStatus>?</web:WOStatus>\ 
    <web:WONum>?</web:WONum>\ 
    </web:UpdateWO_Input><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://siebel.com/WebService">\ 
    <soapenv:Header/>\ 
    <soapenv:Body>\ 
    <web:UpdateWO_Input>\ 
     <web:Comments>?</web:Comments>\ 
     <web:WOStatus>?</web:WOStatus>\ 
     <web:WONum>?</web:WONum>\ 
    </web:UpdateWO_Input>\ 
    </soapenv:Body>\ 
    </soapenv:Envelope>\ 
    </soapenv:Body>\ 
    </soapenv:Envelope> ' 

    var myObj=new Array(); 
    var index = 0; 
    $(document).ready(function(){ 
    $(xml) 
    .find('UpdateWO_Input').find('Comments') 
    .each(function(){ 
     myObj[index] = $(this).text(); 
     index +=1; 
    }); 

    for(var i =0; i< myObj.length;i++){ 
     $('body').append(myObj[i]+"<br/>"); 
    } 

    }); 

    </script> 

    <meta charset=utf-8 /> 
    <title>JS Bin</title> 
    <!--[if IE]> 
    <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"> </script> 
    <![endif]--> 
    <style> 
     article, aside, figure, footer, header, hgroup, 
      menu, nav, section { display: block; } 
    </style> 
    </head> 
    <body> 

+2

Mögliche Duplikat [jQuery XML Namespaces Parsen] (http://stackoverflow.com/questions/853740/jquery-xml-parsing-with-namespaces) –

+0

fand ich Es ist teilweise nützlich. Vielen Dank –

Antwort

1

bekam ich die Antwort auf meine Frage. Unten Änderung der JavaScript-Code erforderlich ist

var myObj=new Array(); 
    var index = 0; 
     $(document).ready(function(){ 
     $(xml) 
    .find('web\\:UpdateWO_Input') 
    .each(function(){ 
     myObj[index] = $(this).text(); 
     index +=1; 
    }); 

    for(var i =0; i< myObj.length;i++){ 
     $('body').append(myObj[i]+"<br/>"); 
    } 

    }); 
Verwandte Themen