Jump to content

Editing prepopulated form


Go to solution Solved by Jacques1,

Recommended Posts

Hi,

I have been reading up on ajax using jquery, and theres something I can't seem to find, i have a form that gets the field values from mysql when the page loads, what is the best way to use ajax to edit this form?  Obv the ajax request will execute the mysql update statement but how do i get the edited data back into the form, ready to be worked with again.

thanks, hope i made sense,  just looking for a little direction.

MsKazza

Link to comment
https://forums.phpfreaks.com/topic/301867-editing-prepopulated-form/
Share on other sites

Oh right, so whatever is typed into the form basically just stays there?  Ajax just executes the update statement and leaves the page alone.  So in theory i edit a product description, click submit, it executes the update, then i see an error correct it, submit again and again it executes the update while the page stays as I typed it.  

 

**lightbulb moment**

I thought it was somehow refreshing the page without reloading.  

 

In that case If i'm adding something to a mysql table via a form and have the results displayed in a separate div, how is this updated to reflect the new information, do i somehow need to make the div reload?

 

Thanks very much for the quick response.

Ajax simply means that JavaScript makes additional HTTP requests in the background. The page content isn't affected by this in any way. If you want to update parts of the page, you have to do that yourself with JavaScript.

 

For example, if the div element has the ID “status”, then

$('#status').text('Success');

will change the text content of the element to “Sucess”. Generating complex HTML structures like lists is more difficult. If you have a specific question, post your code.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.