2014-04-22 40 views
0

我想從像web服務XML響應:jQuery的AJAX:獲取服務器的XML

function xmlparser() { 
    $.ajax({ 
     type: 'GET', 
     url: URL, 
     dataType: 'application/xml', 
     success: function (xml) { 
      result = $(xml).find("post").text(); 
      text = result; 
      return text; 
     }, 
     error: function (xml) { 
      alert(xml); 
      alert(xml.status + ' ' + xml.statusText); 
      return false; 
     } 
    }); 
} 

,但我總是得到一個誤差函數([目標對象],200 OK)

XML:

 <posts><post>Adolf : get more minerals | </post></posts> 

請幫我解決這個問題

回答

0

使用dataType無效對於xml,改變dataType: 'application/xml',dataType: 'xml',並嘗試

0

而不是使用dataType: 'application/xml',只是用dataType: 'xml',也最好是寫在PHP端頭,這將決定響應爲XML header('Content-type: application/xml');

相關問題