PHP Classes

Re-entrant Ajax from PHP

Recommend this page to a friend!

      Top level forums  >  PHP Specialists  >  General  >  Re-entrant Ajax from PHP  
Subject:Re-entrant Ajax from PHP
Summary:How to cycle Ajax from within PHP
Messages:8
Author:Antonio Gross
Date:2009-07-13 14:40:01
Update:2009-07-15 20:06:41
 

  1. Re-entrant Ajax from PHP   Reply   Report abuse  
Picture of Antonio Gross Antonio Gross - 2009-07-13 18:50:10
A booking system for language classes.
I have an html with several DIVs which exhibit HTML created by PHP.
One of them is a Booking PHP which shows a student's class schedule allowing updates, deletes and inserts. This is shown as HTML echo messages. Once the student has filled out the data, an UPDATE.PHP is called which does the DB processing and issues messages.
Of course the PHP takes over and the original HTML with all its DIVs disapppears. In order to force this output into a DIV thru Ajax I try to run JavaScript, without success. Here is a code schematic.
SCHOOL.HTML
<script type="text/javascript" src="Canuck.js"></script>
function book() {var now = new Date(); var hour = now.getTime();
var nm = document.getElementById("StdNo"); var nmval = nm.getAttribute("value");
getData('booking.php?StdNo=' +nmval+ '&a=' + hour + '','actual');
}
function carrega_loadurl(link,div) {
var vdiv = div; var vlink = link;
document.getElementById(vdiv).innerHTML = getData(vlink,vdiv);}
....
getData is the classic Ajax call. At the moment I am still using GET, but will switch to POST once I find out how to reach the function.
<div id="actual">...</div>
ALL OF THIS WORKS
Now here is booking.php:
<html><head><script type="text/javascript" src="Canuck.js"></script></head></html>
<?php
...
<td><a href=\"#\" onClick=\"carrega_loadurl('update.php','actual');\">Update</a></td>
...
All I get is Error on Page

There are 7 replies in this thread, which are not being displayed.
Browsing this forum thread replies is available only to premium subscribers.


Go to the premium subscriptions page to learn how to become a premium subscriber and have full access to this forum.