the code below read text file using javascript. works. however, want read part of content. example, content of file :"hello world!" want display "hello". tried function split(), works on strings. don't know how insert here.
var urls = ["data.txt"]; function loadurl() { var urltoload = urls[0]; alert("load url ... " + urltoload); browser.setattributens(xlinkns, "href", urltoload); }
thank you!!!
i used
jquery.get('http://localhost/foo.txt', function(data) { var myvar = data; });
, , got data text file.
or try this
jquery provides method $.get can capture data url. "read" html/text document, needs accessible through url. once fetch html contents should able wrap markup jquery wrapped set , search normal.
untested, general gist of it...
var html_file_url = '/whatever/html/file.html'; $(document).ready(function() { $.get(html_file_url, function(data) { var filedom = $(data); filedom.find('h2').each(function() { alert($(this).text()); }); }); });
Comments
Post a Comment