2012-08-23 70 views
5

我正在使用javascript獲得肥皂響應 但經過很多痛苦之後,我意識到無法獲得跨域xml http請求。 所以我決定移動到jquery 現在我不需要代碼到那 我只需要一些提示和確認如果可能在jquery 下面是我的代碼js var getmarket = new XMLHttpRequest(); getmarket.open('POST','http://www.betfair.com/publicapi/',true);是否有可能使用jquery獲得跨域SOAP請求

var m_request = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" '+ 
        'xmlns:bfex="http://www.betfair.com/publicapi/v5/BFExchangeService/" '+ 
        'xmlns:v5="http://www.betfair.com/publicapi/types/exchange/v5/">'+ 
        ' <soapenv:Header/>'+ 
        '<soapenv:Body>'+ 
        '<bfex:getAllMarkets>'+ 
        '<bfex:request>'+ 
        '<header>'+ 
         '<clientStamp>0</clientStamp>'+ 
         '<sessionToken>Y9eTuEvlrTM55pbRB1kIj0As0bVvz3eFm+p1FY+svHk=</sessionToken>'+ 
        '</header>'+ 
        '<locale>en</locale>'+ 
        '<eventTypeIds>'+ 
         '<v5:int>1</v5:int>'+ 
        '</eventTypeIds>'+ 
        '<countries>'+ 
         '<v5:Country>GBR</v5:Country>'+ 
        '</countries>'+ 
        '<fromDate>2012-08-23TO00:00:00.000Z</fromDate>'+ 
        '<toDate>2012-08-24TO00:00:00.000Z</toDate>'+ 
       '</bfex:request>'+ 
       '</bfex:getAllMarkets>'+ 
      '</soapenv:Body>'+ 
     '</soapenv:Envelope>'; 

    getmarket.onreadystatechange = function(){ 
     if (getmarket.readyState == 4 && getmarket.status == 200) 
     document.write(getmarket.responseText); 
     } 

    getmarket.setRequestHeader('Content-Type', 'text/xml'); 
    getmarket.send(m_request); 
    document.write(getmarket.responseText); 

回答

2

jQuery是周圍的Javascript的包裝。如果JavaScript不會這樣做JQuery不會。您必須讓您的服務器執行查找。

2

你不能這樣做,只有JSONP被允許跨域。

也檢查:Cross-domain SOAP from the browser

+0

尼斯網址,尤其是第二個(整個網站)。謝謝,否則就永遠找不到我的路! –