Jump to content

PHP and Ajax question??


moose2004

Recommended Posts

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?? 

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.