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?

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.

Thanks for your reply.

Thats a really good idea!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.