...

View Full Version : Editing using AJAX ??



badHabitZ
07-20-2010, 06:14 PM
Hello people,

I am wondering, I have got a very simple question. I have a page, for example where news is being displayed like below:


Posted by: Administrator

News Message: Lorem ipsum bla bla

Now I want to do the following. When I click on a button, I want to show a text input field where "Administrator" is being displayed, and a text message input field where the news is being displayed, without reloading the page.

Here the example with images:

Step 1
This is what I am seeing on my webpage:

http://img191.imageshack.us/img191/9616/example1u.png

Step 2
Now I click on some button (edit button), and the following is being displayed WITHOUT reloading the page:

Step 3
http://img203.imageshack.us/img203/7843/example2e.png

So what I am getting basically, is an edit form so I can directly edit the news and then hit the "edit" button again to post the edited news.

Can someone tell me if this is indeed done with AJAX and if so (or not) can someone point me in the right direction by showing me a tutorial of how to accomplish this, so I can get started with it? The only thing I need is the "function" to show the edit form without reloading the page.

Thanks in advance.

Rowsdower!
07-20-2010, 08:43 PM
Yes. The initial switch-over to editing mode is javascript all by itself - no biggie. Actually sending the new data to the server to be saved is done with what we call "AJAX."

You set up the "save" button or whatever to send an http_request using either "post" or "get" (I'd stick with post for this). Then on the server you have a page set up to have the javascript send to that takes the data, validates the input to make sure it's legit, and then updates your database with the new post information.

This is definitely AJAX though, so yeah. You're on the right track.

badHabitZ
07-20-2010, 09:07 PM
Yes. The initial switch-over to editing mode is javascript all by itself - no biggie. Actually sending the new data to the server to be saved is done with what we call "AJAX."

You set up the "save" button or whatever to send an http_request using either "post" or "get" (I'd stick with post for this). Then on the server you have a page set up to have the javascript send to that takes the data, validates the input to make sure it's legit, and then updates your database with the new post information.

This is definitely AJAX though, so yeah. You're on the right track.

Okay, sounds cool, I'll look into that tomorrow then and if I need some help finding some tutorials, I'll post in here again :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum