EchoFool Posted June 1, 2012 Share Posted June 1, 2012 Hey I'm wondering if there is any way to call a HTML file in JavaScript and also parse a JS array. I have a html file which has a table but i want to loop my JS array into that table as rows of data. Is there anyway to do it at all ? Link to comment https://forums.phpfreaks.com/topic/263451-call-a-file-and-loop-a-js-array-in-side-it/ Share on other sites More sharing options...
goodacre.liam Posted June 8, 2012 Share Posted June 8, 2012 My interpretations: A. You are wanting to use an html file as a template for inserting data into and then attaching into your current web page. B. You are wanting to read an html file and extract data from it. For A, have a look at JavaScript templating libraries such as Handlebars.js {http://handlebarsjs.com/} or Moustache.js {https://github.com/janl/mustache.js}. For B, you could create an html entity that isn't attached to the dom. Load the html file via ajax, and use the file contents as the entity's inner-html. Then traverse the entity's children to extract the data required. Regards, Liam Goodacre Link to comment https://forums.phpfreaks.com/topic/263451-call-a-file-and-loop-a-js-array-in-side-it/#findComment-1352293 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.