PHP Classes

File: transferevents.php

Recommend this page to a friend!
  Classes of Jo Giraerts   cjEvents   transferevents.php   Download  
File: transferevents.php
Role: Auxiliary script
Content type: text/plain
Description: Ajax handler
Class: cjEvents
Handle browser events in PHP
Author: By
Last change:
Date: 13 years ago
Size: 1,059 bytes


Class file image Download
include_once 'event.php';
'mycallbacks.php'; // the callbacks that are gonna be used to handle the events


$handler = cjEventHandler::singleton();
// Setting up a handler for the events that are coming from javascript
$handler->attach('phpevent1', 'answerjsevent');
$handler->attach('phpevent2', 'answerjsevent');

// Work out the events we got from javascript

     * Only use this if you are sure that all callbacks that are defined can be called in this script.
     * So you need to make sure everything is set up before doing a call to handle()
     * Best practice would be to collect all your callback-classes and functions in an include-file and instantiate all the objects
     * that serve as callbacks in that file too. This way you can include that file in all the places where you handle PHP-events

// Now send all the js-events from PHP to the frontend