0

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??

2
  • 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. Commented Dec 23, 2014 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(); Commented Dec 23, 2014 at 16:45

1 Answer 1

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/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.