Database updating question with JavaScript and local storage
Hi all,
I am coming from a PHP background and a newbie with HTML5 and JavaScript and local storage
Currently I'm trying to build a mobile web app that uses a remote Database.
I have a question about database updating.
Currently, I have It set up so when the User logs in successfully – Local storage fields are loaded from the remote database query using a jQuery.get(). This seems to work well.
When it's time to update the data, I populate form fields from the local storage, let the user edit the fields, then:
- use a form post to send the data to the remote php page, which updates the database.....
here's where I have a question: How do I make sure the edit went through okay - what's best to do now?
- I can set up a json response to say if the update was successful or not
or
- Query the database once again and retrieve the fields To compare them to the edit results
or
- Some other technique to Make sure the edit went through okay
- then if successful, I can update the local storage
Q: What is the best way to make sure That the database was updated correctly (and also not waste time with unneeded database access)?
Is there a best practices for this?
Also if possible this newbie could use a clear example...
