jquery - Using Javascript/PhoneGap to access a txt file on server -
this question has answer here:
i trying access text file (stored on server) storing coordinates in order parse , store in phonegap application. i'm new javascript, possible do? i've searched around while , can't seem figure out on own. appreciated.
thanks, molly
you can use xmlhttprequest fetch text, assuming text file publicly accessible. use like:
var req=new xmlhttprequest(); req.open("get", "txt_file_url", true); req.onreadystatechange=function () { if (req.readystate==4) { var txt=req.responsetext; // text } }; req.send();
unfortunately, asynchronous; if need synchronous way, try using async.
Comments
Post a Comment