( ! ) Warning: session_start(): open(/tmp/sess_d9decc5cb9c730a04e86fa18a022152d, O_RDWR) failed: Disk quota exceeded (122) in /www/noahlabs/jwee/init.php on line 7
Call Stack
#TimeMemoryFunctionLocation
10.0011383672{main}( ).../index.php:0
20.0015396944include( '/www/noahlabs/jwee/init.php' ).../index.php:3
30.0015396944session_start ( ).../init.php:7
Variables in local scope (#2)
$Browser =
/www/noahlabs/jwee/init.php:7:*uninitialized*
$Session =
/www/noahlabs/jwee/init.php:7:*uninitialized*

( ! ) Warning: session_start(): Failed to read session data: files (path: /tmp) in /www/noahlabs/jwee/init.php on line 7
Call Stack
#TimeMemoryFunctionLocation
10.0011383672{main}( ).../index.php:0
20.0015396944include( '/www/noahlabs/jwee/init.php' ).../index.php:3
30.0015396944session_start ( ).../init.php:7
Variables in local scope (#2)
$Browser =
/www/noahlabs/jwee/init.php:7:*uninitialized*
$Session =
/www/noahlabs/jwee/init.php:7:*uninitialized*
Ajax, The Wee Easy Way - Noah Ellman - Javascript Toolkit
mrspoonzy at gmail Cube by Noah Ellman A powerful javascript toolkit, in research © by Noah Ellman

Ajax, The Wee Easy Way

wee.AjaxClass AjaxClass()
get(...)
post(...)
getHeader(...)
setHeader(...)
running
text
status
request { }
response { }
http { }

Ajax functionality is accessable from the wee.ajax kit, which is itself an automatically created instance of the wee.AjaxClass object. Rather than creating new ajax class instances which uses alot of memory, you can just use wee.ajax.

Unlke other frameworks, jwee's ajax implementation reuses the existing native xmlhttp object rather than creating new ones for every ajax request, which is a tough on javascript's garbage collector and not needed except in unusual circumstances.

The browser cannot and will not make more than two simultaneous socket connections to the same host anyway, so there is no reason to create infinate numbers of ajax objects, as they will execute one after the other anyway, and not all the at the same time.

In large web applications like webmail clients or Facebook where people tend to leave the page open for hours, it is critical to have javascript code that minimizes the chance of memory leaks or event worse - freezing the browser.

class new AjaxClass.AjaxClass()
The ajax class shouldn't be directly accessed except if you know what you are doing. Instead use the wee.ajax instance.

You shouldn't need to worry about AjaxClass. Instead, use wiki.ajax, which is automatically created instance of the class.

method wee.AjaxClass.get(...)( string URL,  [callback or element] ,  [object query_parameters] )
Make an ajax request.
Args
  1. string The URL to call, such as /ajax/foo.php for example.
  2. (optional) Your function callback that jwee should call when ajax request is complete. You can also pass an html element instead.
  3. (optional) Additional query variables that you would like to have encoded and appended to the URL.
Returnstrue or false/null if an error occured

function onAjaxDone( response ) {
	var data = response.text; 
	// Now do whatever you like with your new data
	$('mydiv').update( data );
}

wee.ajax.get( "foobar.htm", onAjaxDone );

method wee.AjaxClass.post(...)( string URL,  [callback or element] ,  [object query_parameters] )
Make an ajax request.
Args
  1. string The URL to call, such as /ajax/foo.php for example.
  2. (optional) Your function callback that jwee should call when ajax request is complete. You can also pass an html element instead.
  3. (optional) Additional query variables that you would like to have encoded and appended to the URL.
Returnstrue or false/null if an error occured


	postData = {};
	postData.login = "foo";
	postData.pass = "bar";

	wee.ajax.post( "login.php", onAjaxDone, postData );

method wee.AjaxClass.getHeader(...)( string header )
Fetch a HTTP header from the ajax result.
Args
  1. string The name of the header, such as content-length or a custom header if you sent one.
Returnstrue or false/null if header does not exist


	function onAjaxDone( response ) {
		var type = response.getHeader('content-type');
		if( type == 'text/json' ) wee.evalScript( response.text );
	}

method wee.AjaxClass.setHeader(...)( string header,  string value )
Set a HTTP header for the next the ajax request.
Args
  1. string The name of the header, such as content-length or a custom header if you sent one.
  2. The string value of the header.


	wee.ajax.setHeader('Content-type','text/xml');
	wee.ajax.get( .... ) // Above header will be sent...

	wee.ajax.setHeader('X-MY-HEADER','foo');
	// make up a special header for your application


Properties

boolean wee.AjaxClass.running
Indicates whether an ajax call is currently running.
AdvancedThis is a advanced level function.

	if( wee.ajax.running ) return;
string wee.AjaxClass.text
The body of the current / last ajax response you have made. This could be html, json string, or javascript code - whatever the server returned.
number wee.AjaxClass.status
The HTTP status returned by the web server, such as 200 for success, or 500 for server error.
object wee.AjaxClass.request { }
An object of properties pertaining to your ajax request
object wee.AjaxClass.response { }
object wee.AjaxClass.http { }
The actual XmlHttpRequest object, available to access directly for custom implementation.
AdvancedThis is a advanced level function.

Discussion on /learn/api/ajax