Integrating various Ajax Frameworks

Seagull is easy to integrate with Ajax projects because its Request object is factorised to handle the basic request types:

  • browser
  • Ajax
  • CLI
  • AMF

Drivers for SOAP and XML-RPC requests could easily be developed but do not currently exist.

In the case of Prototype and jQuery, any Ajax request only needs to specify the module name and the action name, and the relevant method in the module's AjaxProvider will be discovered. Here's an example in Prototype

function saveSection()
	new Ajax.Request(
		 parameters:'groupName=' + $('sectionName').value,

which will map to TodoAjaxProvider::addGroup which looks like this:

    function addGroup()
        $groupName = SGL_Request::singleton()->get('groupName');
        $nextId = $this->dbh->nextId($this->conf['table']['todo_group']);
        $todoGrp = DB_DataObject::factory($this->conf['table']['todo_group']);
        $todoGrp->todo_group_id = $nextId;
        $todoGrp->name = $groupName;
        $todoGrp->order_id = $nextId;
        $success = $todoGrp->insert();
        if ($success) {
            $ret = 'Group added successfully';
        } else {
            $ret = 'There was a problem adding the group';
        return $ret;

Prototype + Scriptaculous

These frameworks are integrated by default in the 0.6 series of Seagull, see the Ajax tutorial for more detail.


jQuery is currently the dominant player in Ajax circles and is very easy to integrate into Seagull. You could either

  • override SGL_Output::makeJsOptimizerLink() so it includes the packed version of jquery, adding to the file array:
$aFiles = array(
    // jquery core
    // ...
  • or you could add it manually to the global config under
$conf['site']['globalJavascriptFiles'] = "js/JQuery/jquery-1.2.3.pack.js"
  • or you could use your current Manager class and add it directly to the display() method


Dojo is quite heavyweight but also an interesting option, see here for more integration details.