Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
please help me to solve this error.

XML
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Hello World</title>
  <script src="jquery.min.js" type="text/javascript"></script>
    <script>
function onError(request, data, status) {
alert(status+"Hii");
    console.log(status);
}

function onSuccess(data, status) {
alert(status+"Hi");
    console.log(data);
}

function loadData() {

    var soapMessage = '<?xml version="1.0" encoding="UTF-8" standalone="no"?><SOAP-ENV:Envelope xmlnsOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://wsendpoints.bbrailapps.firstgroup.com" xmlns:intf="http://wsendpoints.bbrailapps.firstgroup.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ><SOAP-ENV:Body><intf:getVersion xmlns:intf="http://wsendpoints.bbrailapps.firstgroup.com"></intf:getVersion></SOAP-ENV:Body></SOAP-ENV:Envelope>';

    $.ajax({
        url: "http://railapps.firstgroup.com/FirstGroupRailApps/services/RailAppsCAWS?wsdl",
        type: "POST",
        dataType: "xml",
        data: soapMessage,
        processData: false,
        contentType: "text/xml; charset=\"utf-8\"",
        success: onSuccess,
        error: onError
    });
}

        </script>

    </head>
    <body onload="loadData();"></body>
</html>




I am getting error...
POST http://railapps.firstgroup.com/FirstGroupRailApps/services/RailAppsCAWS?wsdl 500 (Internal Server Error) jquery.min.js:4
f.support.ajax.f.ajaxTransport.send jquery.min.js:4
f.extend.ajax jquery.min.js:4
loadData test.html:22
onload test.html:37
Internal Server Error test.html:10

But when change type: "GET",

it load whole XML but nothing having none value..
Posted

1 solution

If the url you are posting to is not in the same domain then it's a cross site scripting error to post. The easy solution, as you have found, is to get.

The value is nothing because you don't pass anything to your success method:

JavaScript
onSuccess(data,status){ //<-- takes args
//blah blah blah
}


$.ajax({
//blah blah blah

success:onSuccess, //<-- not sending args

});



Because your function takes a set of arguments, you need to pass something to it. There is a return implied in ajax, so this should work:

JavaScript
$.ajax({
//blah blah
success:onSuccess(data), // <- now we are passing the return to the function
});


You should get a result from that. For testing it may be easier just to do this:

JavaScript
function loadData() {
 
    var soapMessage = '<?xml version="1.0" encoding="UTF-8" standalone="no"?><SOAP-ENV:Envelope xmlnsOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://wsendpoints.bbrailapps.firstgroup.com" xmlns:intf="http://wsendpoints.bbrailapps.firstgroup.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ><SOAP-ENV:Body><intf:getVersion xmlns:intf="http://wsendpoints.bbrailapps.firstgroup.com"></intf:getVersion></SOAP-ENV:Body></SOAP-ENV:Envelope>';
 
    $.ajax({
        url: "http://railapps.firstgroup.com/FirstGroupRailApps/services/RailAppsCAWS?wsdl",
        type: "POST",
        dataType: "xml",
        data: soapMessage,
        processData: false,
        contentType: "text/xml; charset=\"utf-8\"",
        success: function(data){
            alert('success!');
            console.log(data);
        },
        error: onError
    });
}
 
Share this answer
 
v2
Comments
ravi1989h 26-Sep-12 12:59pm    
i don't understand ....:(
can you do some changes in my code..?
loctrice 26-Sep-12 13:05pm    
see if the updated solution points you in the right direction
ravi1989h 26-Sep-12 13:10pm    
Uncaught ReferenceError: onError is not defined
ERROR
loctrice 26-Sep-12 13:22pm    
did you remove the onError from your original code?
ravi1989h 26-Sep-12 13:27pm    
yes

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900