我正在尝试从 Twitter XML URL 检索数据。在这里,我为它编写了代码。但它不工作。你能告诉我如何使用 XML 和 AJAX 从 URL 中检索推文和用户名吗
<script type="text/javascript">
$.ajax(
{
type: "POST",
url: "https://api.twitter.com/1/statuses/user_timeline.xml?screen_name=rushijogle",
data: "whatever",
dataType: "xml",
async: false,
success: function(xml){
var xmlDoc;
if (window.DOMParser) {
parser = new DOMParser();
xmlDoc = parser.parseFromString(xml, "text/xml");
}
else // Internet Explorer
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = "false";
xmlDoc.loadXML(xml);
}
var $response = $(xmlDoc);
var data = $response.find("favorited").text()
alert(data);
}
});
</script>
演示链接:- http://jsfiddle.net/be9y6/
提前感谢!