0

tl;dr: I want an easy way to retrieve the GET-string that is created by a form to dynamically load the according data without refreshing.

Normally, pressing submit on this form:

<form action = "action.php" method="get">
    <p>
        <input type="text" name="foo" value="bar" />
        <input type="checkbox" name="check" value="true" checked="checked" />
        <input type="submit" />
    </p>
</form>

would create and access this string: action.php?foo=bar&check=true

I would like to access this string without reloading and without having to fiddle it together by iterating form elements (which is what I'm doing at the moment). The aim is to put the string into an XMLHttpRequest if something in the form changes so I can update my data on the webpage accordingly.

1 Answer 1

1
var string = $("form").serialize();

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.