JavaScript - Ajax Responsetext ... Help!
Dear Forum Guys,
I have a problem regarding how to recieve multiple response texts from an Ajax code. That is: I want to recieve multiple "responseText"s from the ajax code so that i can populate my form in an asp page. I would also like to know how i can send multiple asp or javascipt Variables inside the responseText of an Ajax code, so that when ajax does responseText i could use the variables just sent from another page (i.e the variables are recieved by the same ajax code after doing responseText) to do some specific tasks. Thank you. Similar TutorialsEdit: Nevermind
AJAX XMLHttpRequest responseText returns undefined but alert returns expected text. Code: function getFile(fileToOpen) { var xmlhttp; if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else if (window.ActiveXObject) { // code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } else { alert("Your browser does not support XMLHTTP!"); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState==4) { //alert(xmlhttp.responseText); return xmlhttp.responseText; } } xmlhttp.open("GET",fileToOpen,true); xmlhttp.send(null); } Code: document.getElementById('widgetOptionsShadow').innerHTML = '<div id="widgetOptions">' + getFile('/togglePauseInit.php?g=<?php echo $gadgetName; ?>') + '</div>'; RESOLVED Thank you! Greetings all! Im looking for some help regarding responseText, so please have a look im so mad right now because i have been struggeling for hours XMLHttpRequestObject.responseText returns correct value when i do alert(XMLHttpRequestObject.responseText); see line PHP Code: var fnWhenDone = function (XMLHttpRequestObject) { alert(XMLHttpRequestObject.responseText); }; But problem is that i want to save down the response to a variable... so i try to change it into PHP Code: var fnWhenDone = function (XMLHttpRequestObject) { varTest = XMLHttpRequestObject.responseText; }; When i try to alert varTest later i get "Undifined"... im pretty new to javascript and have been stuck for hours ... See full code below PHP Code: var myConn = new XHConn(); if (!myConn) { alert("XMLHTTP not available. Try a newer/better browser."); } var fnWhenDone = function (XMLHttpRequestObject) { alert(XMLHttpRequestObject.responseText); }; myConn.connect("validateSearch.php", "POST", "foo=bar&baz=qux", fnWhenDone); function XHConn() { var xmlhttp, bComplete = false; try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp = false; }}} if (!xmlhttp) return null; this.connect = function(sURL, sMethod, sVars, fnDone) { if (!xmlhttp) return false; bComplete = false; sMethod = sMethod.toUpperCase(); try { if (sMethod == "GET") { xmlhttp.open(sMethod, sURL+"?"+sVars, true); sVars = ""; } else { xmlhttp.open(sMethod, sURL, true); xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1"); xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); } xmlhttp.onreadystatechange = function(){ if (xmlhttp.readyState == 4 && !bComplete) { bComplete = true; fnDone(xmlhttp); }}; xmlhttp.send(sVars); } catch(z) { return false; } return true; }; return this; } Hello guys, i really need help with my code...i was stuck with it for like 4 hours >< I want to display the content of my text file inside the html page in the div tags so i could place it somewhere around th page or change it style etc. Could anyone please help? And another question : Are there any chances to display my text data, which is one number in the input box ? Quote: <HTML><HEAD> <SCRIPT language = "Javascript"> objXml = new ActiveXObject("Microsoft.XMLHTTP"); var datafile = "G:\data.txt"; objXml.open("GET", datafile, true); objXml.onreadystatechange=function() { if (objXml.readyState==4) { display(objXml.responseText); } } objXml.send(null); function display(msg) { mydiv.innerHTML = msg ; } </SCRIPT> <BODY> <input type='button' onclick='display(msg)' value='Display'/> <div id="mydiv"></div> </BODY> </HTML> I am wondering how can I return the variable senttext from the function below? I have declared it and when I alert(senttext) below it appears as I want it but I need to return it and pass it to another function. When I change alert() to return the variable becomes undefined??? var senttext; function getData() { if (window.XMLHttpRequest) { req = new XMLHttpRequest(); } else if (window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); } req.open('GET',"http://www.site6.certcoordering1.com/Download/recall.txt" ); req.onreadystatechange = function() { if (req.readyState == 4) { if (req.status == 200) { senttext ='<table style="border:thin black solid"><tr><td><h2>Recent</h2></td><td><h2>Recalls</h2></td><td></td><td></td></tr>' ; var ad2 = req.responseText.split("\n"); for(i=0; i<ad2.length-1; i++) { // now split by comma var ad3 = ad2[i].split(","); senttext += '<tr><td><p>'+ad3[0]+'</p></td><td> <a href="http://www.site6.certcoordering1.com/Download/'+ad3[2]+' rel="nofollow" target="_blank">'+ad3[1] +'</a></td><td></td></tr>' } senttext += '</table>' ; alert(senttext); // I need to return senttext, not alert! When I send it it becomes undefined? } else { alert('File did not load correctly.'); } } } req.send(""); } Hi, I am hoping I just need to be pointed in the right direction with this. I have Page1. When Page1 body onloads it uses Ajax to call PartA Within PartA I have a message board so members can write messages which will be sent to my database in PartA[1] and immediately posted for view on to PartA[2]. As I want to have my request to the server updating regularly I want to have PartA[2] on a timed loop to refresh - I do not need the content of PartA[1] to refresh. So the order of events would look like this: Page1 | onload call | v PartA / \ V V PartA[1] PartA[2] (loads once) (constantly refreshes) What I am not sure about is that I have <body> and <head> attributes in Page1 only. I have already used my body onload to call PartA (and can't use it to call PartA[2] before PartA has loaded anyway). I do not want the user to have to click a button or do anything to call up PartA[2]. So my question is how would I get PartA[2] to automatically load within PartA? I hope I have made this clear, but if I haven't let me know and I will try again. Hello everyone. I was working on a ajax function and I can't seem to figure out what I'm doing wrong here. I'm kinda new with the prototype method I was wondering if I could get some help figuring out what I'm doing wrong here exactly and how I can fix this. Any help on this would be wonderful. Thanks, Jon W Code: function createAjax() { if(!this.http && window.ActiveXObject) { try { this.http = new ActiveXObject("Msxml2.XMLHTTP" || "Microsoft.XMLHTTP"); } catch(e1) { this.http = false; } } if(!this.http && window.XMLHttpRequest) { try { this.http = new XMLHttpRequest(); } catch(e2) { alert("Sorry we was unable to make a request between your browser."); } } } createAjax.prototype.request = function(url) { var rmd = Math.random(); this.http.open('get', url+"&rmd="+rmd, true); this.http.send(null); this.http.onreadystatechange = this.responseHandler; } createAjax.prototype.responseHandler = function(obj) { if(this.http.readyState == 4) { document.getElementById(obj).innerHTML = this.responseText; } } function ajax(url, obj) { a = new createAjax(); a.request(url); a.responseHandler(obj); } var doAjax = new ajax('ajax.php?name=jon','content'); hi; This is my first post and am abit stuck. I used JQuery AJAX to get data from a different page and show it in my div. This all works fine but now i want the page collected by AJAX to execute a Javascript function which is in the page which request the AJAX page. I have this so far but its not working. This is in the AJAX-ed page. Code: <a href="#" onClick="change_postcode(prompt('Please Enter Your Postcode', 'SW10')"); )">SW10</a> And the page which requested the AJAX page. Code: <script type="text/javascript"> function change_postcode(postcode){ $('#view8').html('<p><img src="http://www.MySite.com/images/loading.gif"/><br />Loading! Please Wait...</p>'); $('#view8').load("http://www.mywebsite.com/include.php?inc=Events&when=&postcode="+postcode); }</script> I though about using top but that didn't work. Code: <a href="#" onClick="top.change_postcode(prompt('Please Enter Your Postcode', 'SW10')"); )">SW10</a> How can i get my AJAX page to execute a Javascript function which is in the page which contains the the AJAX page. Thankyou all for reading my post Paul P.S Am very sorry for my way with words. I need some help with some javascript I am trying to put on an IF forum. http://s7.invisionfree.com/AJAXTEST/index.php At the very top, you will see a link called "on this link". It is an ajax code. If you click on it, a blank alert box comes up. However, if you go he http://commx.info/will/test.html and click on the same link, the alert box has the text I am looking for. It uses the exact same code, so I can't figure out why it works on a plain page and not on an IF forum. Does anyone have any ideas? The code is Code: <html><head> <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"><script> function callback(serverData, serverStatus) { alert(serverData); } function ajaxRequest() { var AJAX = null; if (window.XMLHttpRequest) { AJAX=new XMLHttpRequest(); } else { AJAX=new ActiveXObject("Microsoft.XMLHTTP"); } if (AJAX==null) { alert("Your browser doesn't support AJAX."); return false } AJAX.onreadystatechange = function() { if (AJAX.readyState==4 || AJAX.readyState=="complete") { callback(AJAX.responseText, AJAX.status); } } AJAX.open("GET",'http://commx.info/accounts/codes/shout/ipb13/getChatData.php?lastID=0', true); AJAX.send(null); } </script> </head><body><a href="javascript:ajaxRequest()">on this link</a></body></html> I was wondering if someone would have the time to talk and help explain some Ajax things to me... slowly. I'm trying to make my web sites more dynamic. Like I just need someone I can bounce ideas off and they can walk me through step by step on how to do them. Thanks Shelby i have a html wich i am working on .. Code: <html> <head> <script language="Javascript"> function xmlhttpPost(strURL) { var xmlHttpReq = false; var self = this; // Mozilla/Safari if (window.XMLHttpRequest) { self.xmlHttpReq = new XMLHttpRequest(); } // IE else if (window.ActiveXObject) { self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); } self.xmlHttpReq.open('POST', strURL, true); self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); self.xmlHttpReq.onreadystatechange = function() { if (self.xmlHttpReq.readyState == 4) { updatepage(self.xmlHttpReq.responseText); } } self.xmlHttpReq.send(getquerystring()); } function getquerystring() { var form = document.forms['f1']; var username = form.username.value; qstr = 'u=' + escape(username); return qstr; } function updatepage(str){ var s = str; var a = s.split(','); var a1 = a[0]; var a1_1 = a[1]; var a2 = a[2]; var a2_1 = a[3]; var a3 = a[4]; var a3_1 = a[5]; var a4 = a[6]; var a4_1 = a[7]; var a5 = a[8]; var a5_1 = a[9]; var a6 = a[10]; var a6_1 = a[11]; var a7 = a[12]; var a7_1 = a[13]; var a8 = a[14]; var a8_1 = a[15]; var a9 = a[16]; var a9_1 = a[17]; var a0 = a[18]; var a0_1 = a[19]; var form = document.forms['f1']; form.result1.value = a1; form.result1_1.value = a1_1; form.result2.value = a2; form.result2_1.value = a2_1; form.result3.value = a3; form.result3_1.value = a3_1; form.result4.value = a4; form.result4_1.value = a4_1; form.result5.value = a5; form.result5_1.value = a5_1; form.result6.value = a6; form.result6_1.value = a6_1; form.result7.value = a7; form.result7_1.value = a7_1; form.result8.value = a8; form.result8_1.value = a8_1; form.result9.value = a9; form.result9_1.value = a9_1; form.result0.value = a0; form.result0_1.value = a0_1; } </script> </head> <body> <form name="f1"> <p>Username: <input name="username" type="text" id="username"> <p>Password: <input name="password" type="text" id="password"> <input value="Go" type="button" onclick='JavaScript:xmlhttpPost("/cgi-bin/3sms/smscontacts.pl")'></p> <input name="result1" type="text" id="result1" size="18" maxlength="25"> <input name="result1_1" type="text" id="result1_1" size="11" maxlength="11"><p> <input name="result2" type="text" id="result2" size="18" maxlength="25"> <input name="result2_1" type="text" id="result2_1" size="11" maxlength="11"><p> <input name="result3" type="text" id="result3" size="18" maxlength="25"> <input name="result3_1" type="text" id="result3_1" size="11" maxlength="11"><p> <input name="result4" type="text" id="result4" size="18" maxlength="25"> <input name="result4_1" type="text" id="result4_1" size="11" maxlength="11"><p> <input name="result5" type="text" id="result5" size="18" maxlength="25"> <input name="result5_1" type="text" id="result5_1" size="11" maxlength="11"><p> <input name="result6" type="text" id="result6" size="18" maxlength="25"> <input name="result6_1" type="text" id="result6_1" size="11" maxlength="11"><p> <input name="result7" type="text" id="result7" size="18" maxlength="25"> <input name="result7_1" type="text" id="result7_1" size="11" maxlength="11"><p> <input name="result8" type="text" id="result8" size="18" maxlength="25"> <input name="result8_1" type="text" id="result8_1" size="11" maxlength="11"><p> <input name="result9" type="text" id="result9" size="18" maxlength="25"> <input name="result9_1" type="text" id="result9_1" size="11" maxlength="11"><p> <input name="result0" type="text" id="result0" size="18" maxlength="25"> <input name="result0_1" type="text" id="result0_1" size="11" maxlength="11"><p> </div> </form> </body> </html> now my problem is the password is not sent to the perl script i basicly modified an ajax from another form to do this form. when the "go" is pressed the username is sent and a string is recived and devided into the form inputs.. all i need to do now is send the password along with the username the username variable is "u" i would like the password variable to be "p" any ideas Hi, I was just wondering is it possible to have an onclick() JavaScript function that would use PHP to INSERT a new row into a MySQL table? Like is it possible to put some php into a javascript function that runs when I click the button on my page? Something like that? The PHP updates the MySQL database and the JavaScript tells the PHP when to happen? Just wondering what's the best way to go about that. Hi all, I am using ajax to retreive the content of an xml file on my server. I am using the xmlhttp.responseXML.documentElement to validate that the data is correct. The problem starts when I want to copy this data into a different variable and to access it later. I defined a global variable, and in the response function (which is called after the ajax was served) I am duplicating this node into a different one. the problem is that when I try later to access this variable from functions within the same file it allways null. why is it happenning? is it a scope issue or something else? Code: var xml_config_dom; function loadXMLDoc(url) { xmlhttp=null; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE5, IE6 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=onResponse; xmlhttp.open("GET",url,true); xmlhttp.send(null); } function onResponse() { if(xmlhttp.readyState!=4) return; if(xmlhttp.status!=200) { alert("Problem retrieving XML data"); return; } xml_config_dom=xmlhttp.responseXML.documentElement.cloneNode(true) } i have found a very simple ajaxexample on the internet, when this works i can adept it to my site, but it doesn't work :-( anybody sees why? Code: <div align="center" id="timeval">--:--:--</div> <button id="stop">Stop</button> <script src="jquery.js"></script> <script> $(document).ready(function() { //ajaxTime.php is called every second to get time from server var refreshId = setInterval(function() { $('#timeval').load('ajaxTime.php?randval='+ Math.random()); }, 1000); //stop the clock when this button is clicked $("#stop").click(function() { clearInterval(refreshId); }); }); </script> and the phpscript: ajaxtime.php <?php echo date("g:i:s A"); ?> I am very new to web development and I need a push in the right direction here. This is my problem; I am making a web page that will be used privately by two people. I need to find a way to go to an FTP site that can only be accessed by web browser (that is what IT told me) and download a file that has a constant name "prevhour.log" and save this file to a directory so that it can be read (not sure how, my boss is doing that end) and the data will be dumped, and this data will be extrapolated into a gas gauge style dashboard. I need some way of this to be done as automated as possible. Thank you for your time. Rick Right for day's i've searching for a jQuery/js/ajax script that opens like facebooks box where you can delete things update posts and so on... But i don't want that facebox thing i want a tut where i can buy things that will insert into the database and delete things and sooo on... I've made the box i just want the script for it.... I'm not good with js/jQuery/ajax.... Thanks. First of all sorry if i have posted in the wrong forum! Ok my problem is with an RSS ticker for my website. I am having the error req is not defined. Im hoping its something very simple is the script is much complete! THIS IS THE GRAB.PHP CODE PHP Code: <? // [email]jim-jh@webcoding.co.uk[/email] // ticker stuff - grab remote stream // begin grab.php $_receivedRemoteData = "" ; $_requestedStream = $_SERVER['QUERY_STRING']; if ( preg_match("/http/i", $_requestedStream ) ) { $fp = @fopen( $_requestedStream, "r" ) ; if ( $fp ) { while ( !feof( $fp ) ) { $_receivedRemoteData .= @fread($fp, 1024); } @fclose($fp); } } header("content-type: text/xml") ; print $_receivedRemoteData ; // end grab.php ?> THIS IS THE TICKER.PHP FILE CODE Code: <style> .headlines { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt; font-weight: bold; color: #003366; text-decoration: none; } .headlines:hover { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt; font-weight: bold; color: #003366; text-decoration: none; } .globalheader { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; font-weight: bold; text-transform: uppercase; color: #990000; text-decoration: none; } </style> <span align="left" width="100%" id="scroller" style="align:left;z-index:99; position:relative; display;"> <span class=globalheader>BBC NEWS RSS TICKER:</span><br/> <span class="headlines">Loading RSS feeds....</span> </span> <script src="ticker.js"></script> AND THIS IS THE JS CODE WHERE I THINK THE PROBLEM MAY BE. PHP Code: function getRequest() { var con = new Array(); var _ms_XMLHttpRequest_ActiveX = ""; var req; if (window.XMLHttpRequest) { req = new XMLHttpRequest(); } else if (window.ActiveXObject) { if (_ms_XMLHttpRequest_ActiveX) { req = new ActiveXObject(_ms_XMLHttpRequest_ActiveX); } else { var versions = ["Msxml2.XMLHTTP.7.0", "Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP","Microsoft.XMLHTTP"]; for (var i = 0; i < versions.length ; i++) { try { req = new ActiveXObject(versions[i]); if (req) { _ms_XMLHttpRequest_ActiveX = versions[i]; break; } } catch (objException) { // trap; try next one } } } } con[0]=req; con[1]=_ms_XMLHttpRequest_ActiveX; return con; } function loadRSS(url) { //alert("running"); try { if ( _ms_XMLHttpRequest_ActiveX1 ) { rssRequest.onreadystatechange = processRSS; rssRequest.open("GET", url, true); rssRequest.send(null); } else { if (rssRequest) { rssRequest.onreadystatechange = processRSS; rssRequest.open("GET", url, true); rssRequest.send(null); } } } catch ( rssRequestException ) {} } function getChildNode( myElement, naming ) { return myElement.getElementsByTagName(naming)[0].firstChild.nodeValue; } function processRSS() { var cycle = 0; try { if (rssRequest.readyState == 4) { if (rssRequest.status == 200) { response = rssRequest.responseXML.documentElement; if ( response ) { var items = response.getElementsByTagName("item"); for ( var i = 0 ; i < items.length; i++ ) { var title = getChildNode(items[i],"title"); var desc = getChildNode(items[i],"description"); var link = getChildNode(items[i],"link"); rssItems[cycle] = title + " - " + desc; linkItems[cycle] = link; ++cycle; } } } else { alert("There was a problem retrieving the XML data:\n" + req.statusText); } } } catch ( jsException ) {alert(jsException.message);} } var httpArc2 = getRequest(); var rssRequest = httpArc2[0]; var _ms_XMLHttpRequest_ActiveX1 = httpArc2[1]; var rssItems = new Array(); var linkItems = new Array(); function openWindow(url){ window.open(url); } var storyCount = 0; var itemLen = 0; function tickTock(){ var obj = document.getElementById("scroller"); var myTimeout = 50; var str; var st = rssItems[storyCount]; if ( itemLen > st.length ) { storyCount++; if ( storyCount >= rssItems.length ) { storyCount = 0; } itemLen = 0; myTimeout=2000; setTimeout("tickTock()", myTimeout); } else { ++itemLen; str = rssItems[storyCount].toString(); str = str.substring(0,itemLen) + "_"; obj.innerHTML = "<span class=globalheader>BBC NEWS RSS TICKER:</span><br/><a href=\"javascript:openWindow('"+linkItems[storyCount]+"')\" class=headlines>" + str + "</a>"; setTimeout("tickTock()", myTimeout); } } setTimeout("tickTock()", 3000); loadRSS("/grab.php?http://news.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml"); IS THERE ANYONE THAT CAN HELP WITH THIS? hi everyone.. i am using ajax to change the banner background while pressing on refresh Note:it must be a background image because i will display data from database... http://www.graphicano.com/isis/nile_crown2.php please look at this link... my problem is: when i press refresh button in Firefox browser it changes the background and on pressing refresh again the background will change but in internet explorer 8.0 it changes the background only for the first time and on pressing refresh again the background will not change. how i can fix this problem ?? i want the user to press refresh at any time and the background will change.. not only for the first time? at the same time it must be a background image because i will display text from database... I have been successfully using the following "myAjax" function to load text file information from the server. Code: // ajax.js // From: http://www.webdeveloper.com/forum/showthread.php?t=245681 // and: http://www.webdeveloper.com/forum/showthread.php?t=245694 // From: http://codingforums.com/showthread.php?t=143412&highlight=file var myAjax = { TextInformation : '', myAjaxIO : function (U, V) { //LA MOD String Version. A tiny ajax library. by, DanDavis var X = !window.XMLHttpRequest ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest(); X.open(V ? 'PUT' : 'GET', U, false ); X.setRequestHeader('Content-Type', 'text/html'); X.send(V ? V : ''); return X.responseText; }, doLoad : function (filename) { this.TextInformation = this.myAjaxIO(filename); }, getTextInfo : function () { // alert(this.TextInformation); // for testing purposes return this.TextInformation } } /* example function Load_and_Show(filename) { myAjax.doLoad(filename); document.getElementById('TArea').value=myAjax.getTextInfo(); } */ After I load the text file, I store the text "records" into an array by doing something like this: Code: var Recs = myAjax.getTextInfo().split('}'); Where the '}' character is my record delimiter. It could just as easily be '\n' or '\r' or the like. Again, I am not having any problems doing it this way as it suits my current needs. Now the question(s) 1. Does the call to read the text data from the external file always read in the entire contents or can I read one line or delimited record at a time and store it to the array directly without the text storage? 2. If the text is always read completely (my suspicion), can I safely delete the "TextInformation" after I convert to the array format? Is there any memory penalty for doing it this way as the text information can be somewhat lengthly and I don't like the idea of having doubled memory usage when I only need the information in array format anyway? This is the idea I am considering, but I don't know if there are drawback to this method of if there is a better way to accomplish the task. Code: // ajax.js // From: http://www.webdeveloper.com/forum/showthread.php?t=245681 // and: http://www.webdeveloper.com/forum/showthread.php?t=245694 // From: http://codingforums.com/showthread.php?t=143412&highlight=file var myAjax = { TextInformation : '', TextArrayInfo : [], myAjaxIO : function (U, V) { //LA MOD String Version. A tiny ajax library. by, DanDavis var X = !window.XMLHttpRequest ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest(); X.open(V ? 'PUT' : 'GET', U, false ); X.setRequestHeader('Content-Type', 'text/html'); X.send(V ? V : ''); return X.responseText; }, doLoad : function (filename) { this.TextInformation = this.myAjaxIO(filename); }, getTextInfo : function () { // alert(this.TextInformation); // for testing purposes return this.TextInformation }, doArrayConvert : function() { TextArrayInfo = this.TextInformation.split('}'); // assumes '}' is separator character this.TextInformation = ''; }, getTextArrayLength : function() { return this.TextArrayInfo.length; }, getTextArrayAt : function(ptr) { return this.TextArrayInfo[ptr]; } } /* example function Load_and_Show(filename) { myAjax.doLoad(filename); document.getElementById('TArea').value=myAjax.getTextInfo(); } function Convert_to_Array() { myAjax.doArrayConvert(); } var rec = myAjax.getTextArrayAt(0); // gets record element '0' // or rec = myAjax.getTextArrayAt(myAjax.getTextArrayLength()-1); // get last element */ |