Jump to content

[SOLVED] php ajax question - splitting results in two different div's


Recommended Posts

Hi everyone,

 

I wish to split my results from php file and display in two different <div id='1'> </div> <div id='2'>, yes i am using ajax at client side and using php at server side.  At the moment the result is fine and dispalyed in linear way.

 

Any advise, how to split the response received from php files and what do i need to include in my php file to separate the echo statments within my php file.  its probably more an ajax question. i will also post in ajax, sorry if you feel its duplication.

 

Please help.

Try this:

 

In the ajax/js, after the response is received:

var newData = request.responseText;
var response = newData.split("|||");
// update the div, or do whatever with the strings
document.getElementById('1').innerHTML = response[0];
document.getElementById('2').innerHTML = response[1];
...

 

In the php:

<?php
...
// where you are echoing the results:
$results = $div_data_1 . " |||" . $div_data_2;
echo $results;
?>

 

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.