Incomplete Execution of Callbacks on jQuery POST -


I have 2 JS methods that post an AJAX on the server and accordingly do the display results.

1) Delete - Delete the callback on the 'Backup' element and refresh the page

  DeleteRule (ruleId) function {var deleteRuleAction = $ ('# delete) -rule-action '). Val (); $ .post (deleteRuleAction, {ruleId: ruleId}, function (data) {if (data. Status == 'success') {warning (data. Message [0]); $ ('# rule-description-' + rule E) .FadeOut (500); $ ('# div-rule-button-' + ruleId). Fadeaut (500); ActiveArchiveID = Zero;} Other Alerts (Data. [0]); 'Jason' '); }  

2) Save - Save on callback Need to refresh the page to show the newly added element with existing elements

  Function Segment () {Var RuleId = $ ('# rule-id'). Val (); Var saveOrUpdateRuleAction = $ ('# add-or-edit-rule-action') Val (); $ .post (saveOrUpdateRuleAction, {ruleId: ruleId}, function (data) {if (data. Status == 'success') {warning (data. Message [0]); location.Reload (true); // this element The page is considered to be reloaded after saving. // But the page is reloaded when the alert is displayed on the previous line.} Other alerts (data messages [0]);}, 'Jason' ); }  

I call this function to:

& lt; Button type = "submit" onclick = "javascript: save ()" & gt;

Issue: The save callback function is not found at all and the page automatically refreshes during the AJAX call, the object is saved in the database to save. However, the code inside the callback function is not executed.

The following hack was suggested to me to do this work

& lt; Button type = "submit" onclick = "javascript: save (); return back;" & Gt;

I was told that 'return false;' Prevents the page from automatically reloading, however, it does not make sense since my trash, which should not be reloaded, this hack is not intended to prevent it from reloading.

On using Firebug, a deleted post and a return of JSON data. However save (without hacking) showed 'Ebert'

You can check with the normal button. By changing it type = "button"?


Comments