Jump to content
Sign in to follow this  
MsKazza

Editing prepopulated form

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

Share this post


Link to post
Share on other sites

Why do you need to get data back into the form? If you use Ajax, the form content doesn't get deleted at all (unless you do that yourself).

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

No thank you you have sent me in the right direction, I get it now.  Once its updated can send message to page such as 'record updated' but the actual page will stay the same.

 

Thanks very much for your help.

Share this post


Link to post
Share on other sites

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.

Sign in to follow this  

×
×
  • 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.