Cross Domain Post method ajax call using jquery with xml response

前端 未结 3 2011
故里飘歌
故里飘歌 2020-12-11 12:18

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

相关标签:
3条回答
  • 2020-12-11 12:55

    You can write your own script on server on the same domain that does request to the webservicex.net and returns data in any format that you want.

    So, ajax request -> your server (on the same domain) -> webservicex.net

    0 讨论(0)
  • 2020-12-11 13:06

    It seems that server does not support CORS. Then you won't be able to do this with an ajax call due to the same origin policy

    0 讨论(0)
  • 2020-12-11 13:13

    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[^>]*>[\s\S]*?<\/script>/gi, '');
            alert(result);
        }
    });
    
    0 讨论(0)
提交回复
热议问题