1

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

13
  • I don't know if this is part of your issue or not, but you can't have async: false, crossDomain: true and dataType: "jsonp". JSONP has to be async: true because it's implemented via a script tag. Also, why are you using the jsonpCallback option rather than just letting jQuery do the work for you can call your success handler? Commented Mar 18, 2014 at 6:08
  • I tried Without jsonpCallback Option but it shows callback=undefined in the Url.i am stucked here for 2days :( Commented Mar 18, 2014 at 6:17
  • changed async: to true but no changes. Commented Mar 18, 2014 at 6:23
  • Remove the async: false and jsonpCallback: "receive" options and then see if it calls the success handler. Commented Mar 18, 2014 at 6:23
  • Does http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate specifically support the callback=xxx option of JSONP? Commented Mar 18, 2014 at 6:25

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.