使用$ .get方法从asmx页面获取xml数据

时间:2012-09-29 13:52:31

标签: javascript jquery xml web-services asmx

我正在尝试使用$ .get方法从此Web服务获取xml数据: http://www.webservicex.net/currencyconvertor.asmx?op=ConversionRate

我在尝试获取数据时收到错误。

示例代码:

var FromCurrency = "USD";
var ToCurrency = "JMD";
var url = "www.webservicex.net/currencyconvertor.asmx/ConversionRate?FromCurrency="+FromCurrency+"&ToCurrency="+ToCurrency;
var jqXHR;

alert(url);
jqXHR = $jQuery.get(url,function(data){
    alert(data);
})
.success(function() { alert("second success"); })
.error(function() { alert("error"); })
.complete(function() { alert("complete"); });


// Do something here

// Set another completion function for the request above
jqXHR.complete(function(){ alert("second complete"); });

1 个答案:

答案 0 :(得分:2)

经典same origin policy

您可以使用此jsFiddle查看此处转载的错误:http://jsfiddle.net/AWW2S/1/