sure:
Code: Select all
$.ajax({
url:main_url,
dataType:"xml",
cache:false,
timeout: RoarApi.Config.timeout,
data:params,
type:"POST",
controller:controller,
action:action,
callback:callback,
errorCallBack:errorCallBack,
success: function ( data){
RoarApiLog("ajax.success");
RoarApiLog(data);
jsonData=$.xml2json(data);
var d = jsonData[this.controller][this.action];
if (d.status === 'error') {
var callback_code = Roar.UNKNOWN_ERR;
var callback_msg = d.error.text;
if (d.error.type === "0"){
if (d.error.text==='Must be logged in') { callback_code = Roar.UNAUTHORIZED }
if (d.error.text==='Invalid auth_token') { callback_code = Roar.UNAUTHORIZED }
if (d.error.text==='Must specify auth_token') { callback_code = Roar.BAD_INPUTS }
if (d.error.text==='Must specify name and hash') { callback_code = Roar.BAD_INPUTS }
if (d.error.text==="Invalid name or password") { callback_code = Roar.DISALLOWED }
if (d.error.text==="Player already exists") { callback_code = Roar.DISALLOWED }
if (d.error.text==="Must specify name and hash") { callback_code = Roar.BAD_INPUTS }
} //d.error.type === "0"
if (this.errorCallBack!=null) this.errorCallBack( jsonData, callback_code, callback_msg);
}else{ //no errors
this.callback(jsonData);
}
},
beforeSend: function (xhr, settings){
createSpinner("[url=http://www.tiggzi.com/resources/preview/lib/jquerymobile/images/ajax-loader.gif")]http://www.tiggzi.com/resources/previ...[/url];
showSpinner();
},
complete: function (jqXHR, textStatus){
hideSpinner();
},
error: function(jqXHR, textStatus, errorThrown){
this.errorCallBack({status:textStatus,error:errorThrown},Roar.FATAL_ERROR,"ajax error");
}
}); //$.ajax