Banshee PHP framework

AJAX requests

Client side

On the client, you can use Banshee's AJAX class or you can use jQuery's AJAX class. Banshee's AJAX class has a function for both GET and POST requests.

ajax.get(page_id, data, handler)

page_id: the identifier of the page the request has to be send to.
data: URL data to be send with the request.
handler: function to handle the result of the AJAX request.

ajax.post(page_id, form_id, handler)

page_id: the identifier of the page the request has to be send to.
form_id: the identifier of the form containing the data to be send with the request.
handler: function to handle the result of the AJAX request.

The result handler uses one parameter, which is the AJAX javascript object used to send the request. In the result handler, you can use ajax.hasValue(key), ajax.getValue(key) and ajax.getRecords(key) to get data from the result.

Server side

In a controller, you can check the boolean $this->page->ajax_request to see if the current request is a normal request or an AJAX request. The XML that is added to $this->output is will be send as the result of the AJAX request.