0

Hi!

I am using a code to echo a row in a database table using ajax.

The code is working correctly.

The ajax will send the response text as follows-

document.getElementById('outputText').innerHTML = httpObject.responseText;

My question is how can I retrieve individual fields into separate Id's?

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by tuse
0

Hi..
With Ajax, the best way to code is leave the innerHTML blank.. As in dont code anything inside the div tag.. e.g.

<div id="outputText"></div>

Do not put any design in the DIV tag.. Rather, put your design layout in the php file which you access through AJAX..
like...
Suppose $row is the array (whose value is taken from mysql_fetch_array)

echo "<table border='0' width='100%'>";
echo "<tr>";
echo "<td>";
echo $row[0];
echo "</td></tr>";
echo "<tr>";
echo "<td>";
echo $row[1];
echo "</td></tr>";
echo "</table>";

Now you can put this layout from the php file which is called from AJAX in the innerHTML property of the div tag..
This is the best way i could find for using AJAX.

Edited by Reverend Jim: Fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.