ted_chou12 Posted June 23, 2009 Share Posted June 23, 2009 Hi, below are part of my code, but there is something that i don't quite understand: //ajax initial variables... //codes: function ajaxphotocmt(vari) {ajax_request.onreadystatechange = function() {//Call a function when the state changes. if(ajax_request.readyState == 4) {stringarray = ajax_request.responseText.split(";seDp#"); photocomment.title.value = stringarray[0]; alert(); photocomment.message.innerHTML = stringarray[1];}} varis = vari.split(";"); if (varis[0] == "edit") { ajax_request.open("GET", "../admin/ajaxvars.php?ajaxvar=photocommentedit&id=" + varis[1], true); ajax_request.send(null);}} The code works in this order, but not the other way: //ajax initial variables... //codes: function ajaxphotocmt(vari) { varis = vari.split(";"); if (varis[0] == "edit") {ajax_request.onreadystatechange = function() {//Call a function when the state changes. if(ajax_request.readyState == 4) {stringarray = ajax_request.responseText.split(";seDp#"); photocomment.title.value = stringarray[0]; alert(); photocomment.message.innerHTML = stringarray[1];}} ajax_request.open("GET", "../admin/ajaxvars.php?ajaxvar=photocommentedit&id=" + varis[1], true); ajax_request.send(null);}} Can someone please explain to me what is the reason behind it (I am a new to ajax, so i may not know some of the technical things ) Thanks, Ted Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.