只是尝试使用XML
Jquery
函数读取ajax
文件,然后使用回调函数,将文本存储在URLS
var
它不起作用,所以这里是代码,任何提示?
$(document).ready(function(){
var URLS = []
function get_xml(){
var XML_FILE = "file:///home/lwm/repos/get-hyped/resources/data.xml"
$.ajax({
type: "GET",
url: XML_FILE,
dataType: "xml",
success: function(data){
xml_to_data(data);
},
error: function(){
console.log("Can't read the XML file!");
}
});
}
function xml_to_data(data){
// get all urls
$(data).find('links video').each(function() {
URLS = $(this).find('url').text().split(" ");
});
}
get_xml();
console.log(URLS.length);