taxmanrick Posted December 5, 2008 Share Posted December 5, 2008 I know with the split() method, I can take a string and create an array. But I don't want to type in the string, I want to read from a text file because I will have about 65,000 elements to be put into the array. Any thoughts? Can this be done strictly through JS? I am really new to JS and HTML by the way.Thanks in advance for any suggestions. Link to comment Share on other sites More sharing options...
jeffman Posted December 5, 2008 Share Posted December 5, 2008 You probably want to use an AJAX object to get the file data. Where in cyberspace is the file with respect to the browser? On the Internet? On the desktop? Link to comment Share on other sites More sharing options...
taxmanrick Posted December 5, 2008 Author Share Posted December 5, 2008 On my local computer. Link to comment Share on other sites More sharing options...
jeffman Posted December 5, 2008 Share Posted December 5, 2008 This is a very terse bit of programming, but it works, and very well:http://w3schools.invisionzone.com/index.ph...mp;#entry123880 Link to comment Share on other sites More sharing options...
taxmanrick Posted December 5, 2008 Author Share Posted December 5, 2008 Thanks, I will try it. Link to comment Share on other sites More sharing options...
taxmanrick Posted December 5, 2008 Author Share Posted December 5, 2008 I am a bit puzzled. What do the function arguments "U" and "V" represent? What are they defined as? Link to comment Share on other sites More sharing options...
jeffman Posted December 5, 2008 Share Posted December 5, 2008 Here. I'll rewrite this in a more "self-commenting" fashion. function AJAX(url, post_data) { var X = !window.XMLHttpRequest ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest(); X.open(post_data ? 'PUT' : 'GET', url, false); X.setRequestHeader('Content-Type', 'text/html') X.send(post_data ? post_data : ''); return X.responseText;} You still have to work your way through some ternary expressions, but what it's doing is this:Get an AJAX object correct for this browser;Open the object. If there is post data to be sent, open as PUT, else open as GET. DO NOT OPEN FOR ASYNCHRONOUS COMMUNICATION.Set the request header;Send the request. If there is post data, send it, else send an empty string.Return the server's response data. Link to comment Share on other sites More sharing options...
rnd me Posted December 5, 2008 Share Posted December 5, 2008 i wrote IO to fit in a bookmarklet, so the arguments we kept as short as possible.U is the URL, V is not needed in your case. if you want to save data, V is where the data to be placed in the file at the URL goes.Don't pass anything to V.use like var str = IO("data.csv");then the file data is in the string str, which you can handle as you did before. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.