XML to javascript array with jQuery -
i new xml , ajax , newcomer javascript , jquery. among other job duties design our website. deadline near, , way can think of project ajax. have document full of xml objects such 1 repeating:
<item> <subject></subject> <date></date> <thumb></thumb> </item>
i want create array of elements , child elements. i've been reading jquery tutorials on ajax hours , don't know start because assume level of javascript proficiency. if show me easiest way loop through elements , put children array, i'd appreciate tons.
using jquery, $.ajax()
xml file, , on success pass retrieved data each
, like:
var tmpsubject, tmpdate, tmpthumb; $.ajax({ url: '/your_file.xml', type: 'get', datatype: 'xml', success: function(returnedxmlresponse){ $('item', returnedxmlresponse).each(function(){ tmpsubject = $('subject', this).text(); tmpdate = $('date', this).text(); tmpthumb = $('thumb', this).text(); //here can want temporary //variables, e.g. put them in place in html document //or store them in associative array }) } });
Comments
Post a Comment