Hi guys,

I am using this tutorial:


where if you click a button, the the content of my div container is replaced with a message saying thank you for your submission. However, you cannot assign this to a submit button as it just ends up refreshing the page. I need a submit button to submit some items inside a form. Therefore, is there a way to submit the contents of a form and show the message like in the tutorial without the page refreshing to its normal state?

Any help would be fantastic.

7 Years
Discussion Span
Last Post by parry_kulk

Yeah you cannot use submit button as it will refresh the whole page. You will have to use a normal button.
Now in the line
instead of "ajax_info.txt" use the url where you want to submit the form i.e. the one in the action attribute of a form and append the form elements you want to submit to this url.

You can also use POST method to submit form elements through ajax.
See a tutorial here,


I can get it so that it loads the page that the info should be passed to using ajax, but the sessions arent submitted. any ideas?


If you are maintaining sessions by using some hidden input element or url rewriting than I think passing the session parameters in the ajax request should do it.
I have used session tracking APIs in JSP/Servlets so dont have detail idea on this and wont be help to help much

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.