what is difference between server side submitting and client side submitting a form
what is difference between server s开发者_C百科ide submitting and client side submitting a form. Can any one explain with an example.
Thank you
There's no such thing as server-side form posting. (unless of course you have server side code that creates web requests to a different web site and post data there and then reads responses, but based on your question I seriously doubt this is the case)
There are however two types of client-side form postings:
the old-fashioned way by having a
FORM
element withINPUT
elements and a submit button (either anINPUT TYPE="submit"
or aBUTTON TYPE="submit"
);<form method="post" action="some URL that will receive posted data"> <input type="text" name="UserName" /> ... <button type="submit>Save</button> </form>
the new often user-friendlier Ajax posting that doesn't require any particular elements at all; there probably will be for users to enter some data, but sometimes they don't exist at all; example uses jQuery to simplify Ajax posting;
$.ajax({ url: "some URL that will get posted data" data: { UserName: "JohnDoe" } type: "POST", success: function(data, status, xhr){ // do what's required }, error: function(xhr, status, err){ // inform the user about an error } });
The first one has the nasty page loading/refresh/redraw side effect that makes it harder to keep scroll position etc.
The second one relies heavily on Javascript and manipulating DOM elements with results.
If I understand your query, I think you are asking about ways of submitting of a form from a client/browser. a) In plain HTML, you need to explicitly specify the Javascript function to do the form posting in the form element
<form id="form1" onsubmit="JavascriptFunction();" .....>
b) When using ASP.NET framework, you don't have to worry about form posting from the browser, as ASP.NET does this automatically for you. Instead the .aspx pages postback to themselves.
If you need further clarification, let us know
精彩评论