Function ajax_post (the_url, the_param, succ_callback ){
If (typeof ajax_already_setup = 'undefined') ajax_setup ();
$. Ajax ({
Type: 'post ',
Cache: false,
URL: the_url,
Data: the_param,
Success
: Succ_callback
});
}
Function ajax_setup (){
Ajax_already_setup = true;
VaR errorfields = [];
$. Ajaxsetup ({
Error: function (xhr, ajaxoptions, thrownerror ){
VaR jsonresult = NULL;
Try {
Jsonresult = jquery. parsejson (xhr. responsetext );
}
Catch (e ){}
Switch (xhr. Status ){
Case 400:
If (jsonresult = NULL | jsonresult = NULL ){
Return;
}
$ ('. Control-group'). removeclass ('error ');
('.Error-tip-temp'0000.html (''). removeclass ('error-tip-Temp ');
$. Each (jsonresult. Errors, function (idx, data ){
Errorfields. Push (data. Field );
VaR P = $ ('input [name = "'+ data. Field +'"] '). Parents ('. Control-group ');
('.Help-inline', p0000.addclass('error-tip-temp'0000.html (data. msg );
If (! P. hasclass ('error '))
{
P. addclass ('error ');
}
});
Break;
Case 401:
Alert ("Logon timeout, please log on again ");
Location. href = "/";
Break;
Default:
If (xhr. status! = 0)
Alert ("error, Code:" + xhr. Status + ", please try again later ");
Break;
}
},
Complete: function (E, xhr, settings ){
If (xhr! = "Error "){
Errorfields = [];
$ ('. Control-group'). removeclass ('error ');
('.Error-tip-temp'0000.html (''). removeclass ('error-tip-Temp ');
}
}
});
}