html - Is there any way to read a text file in javascript beside using ActiveX? -


given files (html file, text files, etc) on web, there way read text file , print them in textarea beside using activex?

i've tried this, didn't reach goal:

 function getselecteditem(){    var client = new xmlhttprequest();     if(document.codeform.droplist.value == "foo")       client.open('get', 'foo.txt');    else if(document.codeform.droplist.value == "bar")       client.open('get', 'bar.txt');    client.onreadystatechange = function() {       //this displays message in file       alert(client.responsetext);        //but doesn't. displays "undefined" //    document.codeform.source.value = client.reponsetext;    }    client.send(); } 

since display alert message file context, believe there way this. (actually contents of files seem come "client.reponsetext", it's data type domstring, not string.)

any advice appreciated. thanks.

use jquery. http://api.jquery.com/jquery.get/

$.get("http://www.whatever.com/foo.txt", null, function(response){     $("#thetextarea").val(response); // thetextarea id of textarea want put data into. }); 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -