Copy link to clipboard
Copied
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...
Why not use jquery get()'s callback status where if success is returned then update local storage?
best,
Shocker ![]()
Copy link to clipboard
Copied
Why not use jquery get()'s callback status where if success is returned then update local storage?
best,
Shocker ![]()
Copy link to clipboard
Copied
Hi the_shocker,
Thanks much for the help
newbie needs clarification... (I tried looking on web but was unsuccessful finding what I need)
so if I have the form sending this...
$.get("http://mysite.com/edit01.php?ID="+ID+"&firstname="+firstname, function(data, status){
.... etc...
Q: how do I add the callback status to this ?
note: I would like to see something like this....
IF CALLBACK = success
do this...
else
do that...
type thing
Thanks again - DAVE
Copy link to clipboard
Copied
The status return is in the callback function. So you'd so something like this:
$.get("http://mysite.com/edit01.php?ID="+ID+"&firstname="+firstname, function(data, status){
if status == "success" {
// do success stuff here
}
if status == "error"{
alert('an error occurred during your jquery get request');
}
});
best,
Shocker ![]()
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more