我正在尝试使用免费的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
处理程序没有调用它,这个问题的任何解决方案。谢谢