moose2004 Posted April 7, 2009 Share Posted April 7, 2009 Here is the problem I am having... I have an index.php page with a div layer that needs to get handle on another php file that contains a list of variables ONLY with no echo statements and this must be done with Ajax. Now this would be very easy if I just did an include statement at the top of my index.php and typed some code to refresh the page every so often to see the new results but that not very clean to the user. I all ready know how to get a handle on a php file through Ajax if it has an echo statement around the variable I need to display but I have over a 1000 variables so I need to hard code the ones I want in the index.php page. This is what I have used in the past and it works great for pulling the entire file. function MakeRequest(){ var xmlHttp = getXMLHttp(); xmlHttp.onreadystatechange = function(){ if(xmlHttp.readyState == 4){ HandleResponse(xmlHttp.responseText); } } xmlHttp.open("GET", "values.php", true); xmlHttp.send(null); } function HandleResponse(response){ document.getElementById('ResponseDiv').innerHTML = response; } Here is the scenario, user goes to index.php onload I will start a timer to run function MakeRequest() and now here is where in need some help. I need to return all of the variables from the values.php to the index.php page and I will echo out the variables I need from there. Any ideas?? Quote Link to comment Share on other sites More sharing options...
xtopolis Posted April 8, 2009 Share Posted April 8, 2009 Format the php data in XML / JSON and pass it to javascript and only echo the ones you need? Or have the function call the php page with parameters and have php show only the ones that you requested to save time? Your question is unclear.. you're saying you know what to do already and you have AJAX code showing such...perhaps rephrase what you're lacking? 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.