Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: jQuery
Hi
please help me to solve this error.
 
<!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 26-Sep-12 5:43am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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:
 
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:
 
$.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:
 
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
    });
}
  Permalink  
v2
Comments
ravi1989h at 26-Sep-12 12:59pm
   
i don't understand ....:(
can you do some changes in my code..?
loctrice at 26-Sep-12 13:05pm
   
see if the updated solution points you in the right direction
ravi1989h at 26-Sep-12 13:10pm
   
Uncaught ReferenceError: onError is not defined
ERROR
loctrice at 26-Sep-12 13:22pm
   
did you remove the onError from your original code?
ravi1989h at 26-Sep-12 13:27pm
   
yes
ravi1989h at 26-Sep-12 13:28pm
   
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="jquery.min.js" type="text/javascript"></script>
<title>Hello World</title>

<script>

 
function loadData() {

var soapMessage = '';

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

 

 

 
</script>

</head>
<body önload="loadData();"></body>
</html>
NEW CODE
ravi1989h at 26-Sep-12 13:24pm
   
as you give me code i run same code but Uncaught ReferenceError: onError is not defined
is coming
loctrice at 26-Sep-12 13:37pm
   
You needed that onError function still. put it back and it will run.
ravi1989h at 26-Sep-12 13:43pm
   
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="jquery.min.js" type="text/javascript"></script>
<title>Hello World</title>

<script>

function onError(request, data, status) {
alert(status+"Hii");
console.log(status);
}
function loadData() {

var soapMessage = '';

$.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
});
}
 

 

 

 
</script>

</head>
<body önload="loadData();"></body>
</html>
 
Getting same error
loctrice at 26-Sep-12 13:58pm
   
I'm not sure what the problem is with yours. When I linked jquery to the code you have here it worked.
ravi1989h at 26-Sep-12 14:00pm
   
what response you are getting please paste..
loctrice at 26-Sep-12 14:09pm
   
I'm getting the alert box from the on error method.
ravi1989h at 26-Sep-12 20:06pm
   
same i am also getting this , i want to remove this

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

  Print Answers RSS
0 OriginalGriff 6,651
1 Sergey Alexandrovich Kryukov 6,400
2 CPallini 5,230
3 George Jonsson 3,574
4 Gihan Liyanage 2,542


Advertise | Privacy | Mobile
Web02 | 2.8.140921.1 | Last Updated 26 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100