Is there an option getting the query (e.g. ?name=value&...) from a form? what I have done so far is iterating each element in the form and building the query string manually but is there an option avoiding that??
Asked
Active
Viewed 66 times
0
-
Some modern browsers let you simply submit the form with a "FormData" object that constructs that information for you, but I'm not sure it's in enough browsers to use yet. – Katana314 Dec 23 '14 at 16:28
-
Mike's answer is correct. If you want the value of an individual element, you can either give the input and "id" and then use the "id" selector, or you can do something like this. $("input[name='input_name_here']").val(); – 9997 Dec 23 '14 at 16:45
1 Answers
3
You can use jQuery and call .serialize()
on the form element selector.
If you have a form:
<form id="some-form">...</form>
Then you can serialize it with this:
$('#some-form').serialize();
More information: http://api.jquery.com/serialize/

Mike
- 4,071
- 21
- 36