jsonp回调函数未调用错误

时间:2014-03-18 06:00:15

标签: jquery web-services jquery-mobile jsonp

我正在尝试使用免费的webservice http://www.webservicex.net/CurrencyConvertor.asmx?WSDL做一个示例货币转换器移动应用程序我正在使用jQuery mobile和HTML5 for my Application。当我尝试访问webservice时,我收到此错误 错误:未调用receive(receive是我定义的JsonpCallback函数)这是我的Jquery代码

    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>

这是我的Response xml文件

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

错误的丝网印刷:

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

我得到了一个带有语法错误的响应xml,我可以在firebug console中看到它。所以success处理程序没有调用它,这个问题的任何解决方案。谢谢

0 个答案:

没有答案