// instantiate new object
var aa = new Swingjax();
// create url
aa.addURL("www.xyz.com", "test_data.php", false);
// append parameters to send
aa.addParameter("first_name", "john");
aa.addParameter("last_name", "doe");
// assign method
aa.sendMethod = "POST";
// add any additional parameters to querysting
// if needed
aa.queryStringPrefix = "auth=4838jdjhdh87383";
// assign callback function to event that fires
// while request is being processed
aa.onProcessing = is_processing;
// assign callback function to event that fires
// when request has been completed
aa.onCompletion = process_return_data;
// initiate request
aa.sendRequest();
// Note console.log, used below, is provided within Firebug on Firefox,
// replace with alert() if needed.
if (aa.isError == true) {
console.log("Err Msg: " + aa.errorDetail.replace(/\|/gi,"\n\n"));
}
function isProcessing() {
if (aa.isError !== true) {
console.log("Current Status: " + this.transaction_status);
}
else {
console.log("Err Msg: " + this.err_msg.replace(/\|/gi,"\n\n"));
}
}
function process_return_data() {
console.log("Current Status: " + transaction_status);
console.log(this.responseText);
}