If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

How ajax deal with exceptions ?

let say we have an ajax that post some data to the server-side, for example some data to be inserted in a table in the database, I think there are two kind of exceptions that could occur :

1) problem inserting data in the database.
2)ajax communication with server side problem.

so each one of the two exceptions above will send a json message back to the ajax so the user will know that :
1) submit was successful.
2)submit was not successful (problem inserting in the database)
3) submit was not successful because of ajax communication problem.

For me this is the theory, can you please give me an example on how to implement the ajax to deal with the 3 above json messages ?

Ajax does not insert anything, it is merely the medium which carries the data. The use of AJAX is to replace the older form submit so that you can carry out seamless actions in background.

Your receiving script which would live on the server would responsible for returning any control codes to indicate success or not.

Any problems with inserting data would be down to how good you are at programming for that eventuality.

STOP using $ prefix on JavaScript variable names...
Please remember to wrap any code you have in forum tags:- [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]If you can't think outside the box, you will be trapped forever with no escape...