Quite some time i`ve learnt MVC. I have seen various techniques to post data :ajax post and form post.
Is there any other?
I`m quite confused about which technique to use and when?
Can anyone help me on this part?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well, all ways you described above are serving to send the data from your html form to the server for processing.
You were right, you may send this data via form post or ajax post.
The difference is simple.
When you are doing form post, your browser is collecting all parameters from your form and sending it to the server.
While the browser waits for the response, it hangs any activity for the page. After that, the page is blinking and reloading its content.
All that period of time, the consumer of your site feels that he should sit and wait for some time until the window blink and reload its content.
Ajax post does the same as the form post. It collects the data from the page and then sends it to the server.
The main difference, this way does not hangs your browser window.
In this way your application works like windows application. Things are opening, closing, the data is changing, etc.
This way requires of using some script language like javascript or vbscript.
At present moment there is a lot of javascript libraries that helps you. For example, you may use jquery library
So, since there is no difference, its up to you which way to use.
I would recommend to always use firstly form post, because it does not requires any client scripting and its easier to implement.
When you be sure that your application is working in the way you want,you may add some good looking things like ajax posts, so your application will look more friendly to the consumer