Connecting Tech Pros Worldwide Forums | Help | Site Map

updating database using a function

anfetienne's Avatar
Needs Regular Fix
 
Join Date: Feb 2009
Location: UK
Posts: 356
#1: 3 Weeks Ago
hi....(im back lol)

is it possible to write a function that can be called up on everytime someone fills a form and submits it so that all work is done in the same page?

Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,656
#2: 3 Weeks Ago

re: updating database using a function


Quote:

Originally Posted by anfetienne View Post

so that all work is done in the same page?

how do you mean that?
___

Dormi ⇐ has just set up chessidy
anfetienne's Avatar
Needs Regular Fix
 
Join Date: Feb 2009
Location: UK
Posts: 356
#3: 3 Weeks Ago

re: updating database using a function


hey dorm.....i mean.....

say i have a picture and i want to comment on it....i fill in the comment box and click on the submit button.....i dont want it to refresh the whole page, i want a function to run in the background that will post it to a DB and also refresh the connection so the last post can be seen on the page
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,656
#4: 3 Weeks Ago

re: updating database using a function


Quote:

Originally Posted by anfetienne View Post

hey dorm

why is everyone calling me that? it sounds like Dorm the Worm…

Quote:

Originally Posted by anfetienne View Post

say i have a picture and i want to comment on it....i fill in the comment box and click on the submit button.....i dont want it to refresh the whole page, i want a function to run in the background that will post it to a DB and also refresh the connection so the last post can be seen on the page

what you describe is an AJAX request. but I don’t see why anyone should be disturbed by a form submit triggered page reload. (that’s what I’d expect, despite that it works even if JavaScript is disabled)
anfetienne's Avatar
Needs Regular Fix
 
Join Date: Feb 2009
Location: UK
Posts: 356
#5: 3 Weeks Ago

re: updating database using a function


lol im sorry for the name, it;s just shorter to write when im rushing......

what you say is true, but its just the case of having to reload everything on the page....didn't want it to do that but it may be the best option
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,656
#6: 3 Weeks Ago

re: updating database using a function


whatever you do (AJAX or not), it’s your choice. eventually, the code behind is nearly the same.
anfetienne's Avatar
Needs Regular Fix
 
Join Date: Feb 2009
Location: UK
Posts: 356
#7: 3 Weeks Ago

re: updating database using a function


ok thanks for the advice
Reply