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 ? Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.