CtronX (cyclotron) wrote in ajaxengine,
CtronX
cyclotron
ajaxengine

Returning data as text

Hi. I am new to getXMLHTTPRequest() function and var mytext = http.responseText; syntax.

When I return text from PHP like echo "hello moto"; it works fine. But what I really want to do is return HTML created with a MySQL query and PHP



//requested script
require("../addressbook/logininfo.php");
echo "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"2\">";
$Link = mysql_connect ($Host, $User, $Password);
$Query = "SELECT * from todo ORDER BY priority LIMIT 4, 100";
$Result = mysql_db_query ($DBName, $Query, $Link);

if (mysql_db_query ($DBName, $Query, $Link)) {

} else {
//ERROR IN QUERY
print("<br>".mysql_error());
print("<br>$Query");
}

while ($Row = mysql_fetch_array ($Result))
{
include("display.php");
}//end while

mysql_close ($Link);
echo "</table>";

//display.php <tr id="todo<?php echo $Row['record']; ?>">
<form id="<?php echo $Row['record']; ?>">
<input type="hidden" name="item<?php echo $Row['record']; ?>" value="<?php echo $Row['record']; ?>">
<td><?php echo $Row['date']; ?></td>
<td class="c<?php echo $Row['priority']; ?>"><?php echo $priority_list[$Row['priority']]; ?></td>
<td><?php echo $Row['title']; ?></td>
<td><?php echo $Row['description']; ?></td>
<td><input class="button" id="<?php echo $Row['record']; ?>" type="button" name="update<?php echo $Row['record']; ?>" value="update"></td>
</form>
</tr>



When I run the requested PHP+Query by itself, there are no errors. But if I request it with AJAX, it sticks at a readyState of 1.

I was wondering if you guys could tell me why my PHP+query stall. The requested file is in the same dir as the calling page.



SOLUTION

I went line by line commenting out elements of the HTML the php generates and it doesnt like the form tag. It wont let me insert a form with AJAX.
  • Post a new comment

    Error

    default userpic
  • 9 comments