It's not clear why you don't use the form functionality itself with the button of the "submit" type, which is designed specifically to send request to the server. The request is not Ajax, but it is composed in a standard way, by key-value pairs, where the keys values are based on the values of the
name
attributes of input control. If the server part is yours, this is the simplest and standard way to send HTTP requests already fully implemented for you.
I can imagine that you cannot do it though. For example, if the server part is not yours and expects what it expects, the HTTP request data in some exact form, using the "get" method. Then you may really need Ajax.
But in this case, the element form would do nothing. Get rid of it. Moreover, you don't need those
name
attributes. As soon as you don't have an input of "submit" type, the form element is redundant by definition. I would advise to use only the
id
; don't forget they should be unique in the page.
Collecting the data using jQuery is quite simple. First, you need to get all jQuery wrappers of the controls in question. As I advised you to use the
id
, you will need
ID selectors, for example, you will have the wrappers as
$("#Date1")
,
$("#Date1")
, etc. Please see:
http://api.jquery.com/id-selector/[
^].
If you still want to use the
name
attributes, you can use the
name selectors:
http://api.jquery.com/attribute-equals-selector/[
^];
please see other selectors:
http://api.jquery.com/category/selectors[
^].
And then you get read values of the input controls using jQuery
.val()
. For example:
firstText = $("#Date1");
firstText.val();
Please see:
http://api.jquery.com/val[
^].
—SA