Ajax Framework API Table
API | Params | Description |
---|---|---|
$ajax->call() |
$url - required string
$cointainer_id - optional string $confirm - optional string |
Allows you to perform ajax requests. If $container_id is specified, the response of the request will be sent in the container. If $confirm is specified, a prompt for confirmation in form of question is displayed before the request is performed. |
$ajax->form() |
$url - required string
$form_id - required string $confirm - optional string |
Allows you turn a form into an AJAX-form. If $confirm is specified, a prompt for confirmation is displayed before the form is submited. |
$ajax->overlay() |
$url - required string
$use_cache - optional boolean $options - optional array
top - position from top of the page
left - position from left transparent - from 1 to 100 level of background transparency. color - color of the background |
Displays a lightbox overlay on the screen by supplied content request from a url. If $use_cache is specified, it will only request url content once and place it in cache. |
$ajax->dialog() |
$content - required string
$title - optional string $options - optional array
top - position from top of the page
left - position from left transparent - from 1 to 100 level of background transparency. color - color of the background |
Uses overLayContent to display a dialog formatted screen. |
$ajax->overlayContent() |
$content - required string
$options - optional array
top - position from top of the page
left - position from left transparent - from 1 to 100 level of background transparency. color - color of the background |
Displays supplied content in a lightbox overlay. |
|
$btn_id - required string
$target_directory - require string $options - optional array
url [string] - post form to a controller or url.
ext [array] - extensions allowed eg: array('gif','png','pdf') form_id [string] - you can specify the form id, will try detect it otherwise. text [string] - the "Uploading File(s)" indicator, you may costimize the text here. prefix [string] - a prefix can create unique names for uploads avoiding them being overwritten, prefix goes at the start of the file name. sufix [string] - a sufix can create unique names for uploads avoiding them being overwritten, subfix goes at the end of the file name. files_require [boolean default true] - if no files are selected, shows a message "No files were selected". |
Note: This API is not longer supported, and has been moved into an stand alone plugin.
See: http://cjax.sourceforge.net/examples/plugin_upload_files.php
[Cjax 5.0+] Upload all files in a form using Ajax $btn_id - button id is required to obtain parent form. You may upload one or as many files as you need. $target_directory - where files will be uploaded to. $options array - All options are optional. url In addition to uploading the files, you may still post the form to a controller, the form will be posted after the files are uploaded. prefix Can allow unique names. using: 'time' keyword adds a timestamp, using 'rand' keyword adds a random number. If you use the url option, the converted names will be returned as POST variables - $_POST['files'] to the form, and be posted to the url if provided. sufix Can allow unique names, similar to prefix, but applied to the end of the file name. files_require -(if false) hides error message "No files were selected". |
$ajax->Exec() |
$element_id - required mixed[string,array]
$actions - require mixed API $event - optional string [default click]
click
keyup keydown blur |
Bind APIs to elements. $element_id - you may pass more than one element by spliting the id with a vertical bar "|", you may also supply an array. $actions - any API on this table such as $ajax->call() can be binded to an element. You may also supply mutlple APIs in an array. |
$ajax->message() |
$message - required string
$seconds - optional integer [default 3] |
Displays supplied text/content on the screen in form of message. if $seconds is provided, that is how long the message will last on the screen before it disappears, 0 would remove time limit. |
$ajax->success() |
$message - required string
$seconds - optional integer [default 3] |
Makes use of $ajax->message() to display a success formatted message. |
$ajax->warning() |
$message - required string
$seconds - optional integer [default 3] |
Makes use of $ajax->message() to display a warning formatted message. |
$ajax->info() |
$message - required string
$seconds - optional integer [default 3] |
Makes use of $ajax->message() to display a info formatted message. |
$ajax->error() |
$message - required string
$seconds - optional integer [default 3] |
Makes use of $ajax->message() to display a error formatted message. |
$ajax->update() |
$element_id - required string
$data - optional string |
Update element with HTML. You may also use update() to update element values. |
$ajax->wait() | $seconds - required integer | Sets a timeout to the next API used. |
$ajax->location() | $url - required string | Redirect page |
$ajax->alert() | $message - required string | Display alert |
$ajax->focus() | $element_id - required string | Set focus to input or element |
$ajax->remove() | $element_id - required string | Remove an element from the page |
$ajax->debug | boolean variable - true or false [default false] | Debug console mode compatible with firebug. |
$ajax->log | boolean variable - true or false [default false] | Debug PHP output before is processed (stops the application). |
AJAX_CD | AJAX_CD - String Constant [default 'controllers'] | Define where the controllers directory is. By default the controllers directory is "controllers", and you don't need to worry about defining it. However if you happen to use a different controllers directory, you may defined it with AJAX_CD, and will seek for controllers there. If you do define it, make you sure you do it before you include file ajax.php. |
AJAX_VIEW | AJAX_VIEW - Boolean Constant [default false] | If you wish to view the response on the browser, by default the framework will not allow you for security reasons, you may bypass that by defining AJAX_VIEW. |