Quantcast
Channel: Editor — DataTables forums
Viewing all articles
Browse latest Browse all 3800

Editor: ajax function, question about Error callback vs return: false

$
0
0

Long story short, I'm processing data from SQL manually for Editor. I'm using JavaScript. Basically, I pass the success callback function as a parameter to another part of my application that receives/processes the data returned from SQL. Of course, I make sure I structure the data appropriately for Editor's success callback function.

/*
PSEUDO CODE !! :)
*/

//Editor:  Ajax configuration for form data submission. 
ajax: function (method, url, data, successCB, error) {

     //manipulate the form data here
     doTheThing(successCB);

};

//elsewhere in my application
doTheThing:  function (data, options) {

     successCB = options;
     jsonStructureFromServer = data;

     successCB(jsonStructureFromServer);

};

My question:

I know the expected structure for the success callback; however, what is the expected json structure for the error callback? What does the error callback function do?

Basically, my JavaScript app handles errors from SQL in a specific way. If data is submitted, and SQL kicks back an error, no JSON is returned for the success callback to act upon, and the opened form just hangs.

I assume I should use the error callback to handle errors from SQL? I'm pretty sure I can pass the error callback function to the area of my application that handles errors.

What's the best way I can tell Editor that an error occurred on the server, and it should just close the open form?


Viewing all articles
Browse latest Browse all 3800

Trending Articles