Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I want to send a ajax request using post method with the xml as a response text , Is it possible , If it is possible please let me know the possible way for it.

For Ex

url : "http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate"
data : {FromCurrency:"INR",ToCurrency:"AUD"}
method : GET or POST

http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency=INR&ToCurrency=AUD

I need the response of this url using ajax.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
246 views
Welcome To Ask or Share your Answers For Others

1 Answer

You can use YQL,

var url = 'http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency=INR&ToCurrency=AUD'; // website you want to scrape
var yql = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent('select * from xml where url="' + url + '"') + '&format=json&callback=?';  
$.getJSON(yql,function(data){  
    if(data.query.results){
        var result = data.query.results.double.content.replace(/<script[^>]*>[sS]*?</script>/gi, '');
        alert(result);
    }
});

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...