2

I have a form with many input elements inside that looks like:

<form>
  <input name="foo[abc]" />
  <input name="foo[def]" />
  ...
</form>

(foo should be a array inside $_POST)

How can I send these values trough AJAX, without having to manually enter each value in the data parameter?

3 Answers 3

3

use:

var data=$(your_form).serialize();

and send this data using ajax.

it'll automatically convert all array like inputs and normal to a string like get method..

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

Comments

1
$("form").serialize();

Comments

-1

Use the serialize function; see an example here (it's a $.post(), but same difference).

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.