jsonp callback function not called error

1.1k views Asked by At

I am trying to do a Sample Currency Converter Mobile Application with the help of free webservice http://www.webservicex.net/CurrencyConvertor.asmx?WSDL I am using jQuery mobile and HTML5 for my Application.When trying to access the webservice I am getting this Error Error:receive is not called(receive is a JsonpCallback function which I defined) Here is my Jquery Code

    script type="text/javascript" charset="utf-8">
   function receive(result){
        console.log(result)
     }

 $( document ).on( "pagecreate", "#home", function( event ) {
     //alert( "This page was just enhanced by jQuery Mobile!" );
    $("#submit").bind("tap",function(){
        // alert("called");
        // var ConversionRate =$("#value").val();
        // console.log(ConversionRate)
         var FromCurrency = $("#fromcurrency option:selected").val();
         console.log(FromCurrency)
         var ToCurrency = $("#tocurrency option:selected").val();
         console.log(ToCurrency)



         $.ajax({
            crossDomain: true,
            type:"GET",
            contentType: "content/xml; charset=utf-8",
            async:false,
            url: "http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate",
            data: {FromCurrency :FromCurrency,ToCurrency :ToCurrency},
            dataType: "jsonp", 
            jsonpCallback: "receive",
            success: function(result){
                console.log("Success")
            },
            error: function(XMLHttpRequest, textStatus, errorThrown){
                console.log(XMLHttpRequest, textStatus, errorThrown)
                console.log(XMLHttpRequest.responseType)
            }
        });
    });
});


</script>

Here is my Response xml File

<?xml version="1.0" encoding="utf-8"?>
<double xmlns="http://www.webserviceX.NET/">61.155</double>

Screenprint of Error:

http://s28.postimg.org/f11gvkgyl/Error.jpg

I got a response xml with a Syntax Error which i can see it in firebug console.So it is not called by success handler,Any solutions for this problem.Thanks

0

There are 0 answers