Subversion Repositories cryptochat

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 daniel-mar 1
SAJAX PHP BACKEND
2
-----------------
3
 
4
Contributed and copyighted by Thomas Lackner (http://www.modernmethod.com/) and Anders Jenbo.
5
 
6
If you are using PHP < 5.2 you will need to a substitue for JSON_encode and JSON_decode, you might want to try this out http://abeautifulsite.net/notebook/71
7
 
8
Usage:
9
sajax_export() takes a list of functions that are alowed to be called from javascript, there are 4 parameters for each function you send to sajax_export. If strings are used in stead of arrays the functions will just have all options set to there default (like in older versions of Sajax).
10
 
11
name = the name of the function (requred)
12
method = GET : POST (default is GET)
13
asynchronous = true : false (default is true, if set to false the script will pause untill the call has been compleated)
14
uri = the uri where the function lives.
15
 
16
The default method can be changed by setting $sajax_request_type to "POST" (this can also be done at runtime).
17
The default uri can be changed by setting $sajax_remote_uri (this can also be done at runtime).
18
 
19
Sample:
20
sajax_export(
21
	"myFunction",
22
	array("name" => "myPostFunction", "method" => "POST"),
23
	array("name" => "sleep", "asynchronous" => true),
24
	array("name" => "myOffSitefunction", "uri" => "http://myotheresite.com/ajax.php")
25
);
26
 
27
sajax_export() may be called multiple times.
28
 
29
To get debug alert's set $sajax_debug_mode to true.
30
 
31
You can redirect the users browser to a frindly error page incase his/her borwser issn't supported by sajax by setting $sajax_failure_redirect to an URI.
32
 
33
Calling sajax_get_common_js() will print the client side script.