Note: if you are testing in Netscape Navigator or Firefox for Firefox <= 1.0 you cannot run these tests locally on your computer. You must run them from http://forkjavascript.org/ajax/tests . This is because these old browsers will not allow POST requests to localhost.
new FORK.Ajax('GET', '/ajax/simple',
{
onSuccess: function(o) {
document.simpleForm.pagesource.value = o.responseText;
}
}
);
new FORK.Ajax('GET',
'/ajax/missing',
{
onSuccess: function(o) {
alert("success");
},
onComplete: function(o) {
alert("Error!\nStatus = " +
o.status +
"\nContents = " +
o.responseText);
}
}
);
new FORK.Ajax('POST', '/ajax/form',
{
form: "exampleForm",
onSuccess: function(o) {alert("success");},
onComplete: function(o) {alert("failure");}
}
);
document.getElementById('throbberGif').style.visibility = 'visible';
new FORK.Ajax('GET', '/ajax/throbber',
{
before: function(o) {
document.getElementById("throbberGif").style.visibility =
"hidden";
}
}
);
This example polls 10 times. Each poll starts one second after the last one finished.
Polls:
Watch in Windows' Task Manager's System Performance Tab for memory use. The server returns a 10 MB file for each request and during the polling the memory use should show garbage collection at times.
new FORK.Ajax('GET', '/ajax/leak');
Disabled on public site to conserve bandwidth
Leak Polls:
Press the Go link many times and wait for the numbers to disappear. Eventhough the server takes a long time to respond, the requests wait in line. If your server can only handle one request at a time then the numbers should disappear at roughly even intervals. If your server can process more than one request simultaneously you may see the numbers disappear at uneven intervals which is good. The Fork site currently can handle two processes and so the numbers disappear roughly in pairs.
new FORK.Ajax('GET', '/ajax/leak');
Sever sleeps for 5 seconds but request is aborted after one.
new FORK.Ajax('GET', '/ajax/sleep_long',
{onComplete: function(o){
alert("server responded");
}}
);
TODO need a test for abort memory leak in IE
The server takes too long to respond and the Ajax request times out after two seconds.
new FORK.Ajax('GET', '/ajax/sleep_long',
{onComplete: function(o){
alert("server responded");
},
timeout: 2000,
onTimeout: function(o) {
alert('timed out');}
}
);
TODO need a test for timeout memory leak in IE