tags:

views:

39

answers:

3

hey,

I just want to know what is the difference between sending parameter with ajax(post/get) to a servlet and sending them with "submit" .

Thanks for your help.

+1  A: 

At the simplest, with ajax, you don't witness page refresh while submitting form data. And if you don't use it eg you use submit buttons, you witness page refresh. Both submit the data.

Sarfraz
thanks it is more clear now.
kawtousse
@kawtousse: You are welcome :)
Sarfraz
A: 

From the servlet's point of view there is no difference. For the client, a submit will load a new page, while an Ajax request will parse the response with javascript code and act accordingly.

kgiannakakis
+6  A: 

A standard form submit sends a new HTTP request (POST or GET) and loads the new page in the browser. In Ajax, the data is sent to the server (POST or GET) in the background, without affecting the page at all, and the response is then received by javascript in the background, again without affecting the page at all.

(The javascript can, of course, then use the data received from the server to update some of the page content.)

Ajax is generally useful where only a small section of the page content will change.

TRiG
thanks it is more clear now
kawtousse
You're welcome. Glad I could help.
TRiG