blue_zinc
blue_zinc

Reputation: 2500

jQuery: Posting an array quirk with square brackets

I'm using the following code to make a post.

var checked = ["2231","2432"];

jQuery.ajax({
            type: 'post',
            url: statusUrl,
            data: {"entries":checked},
...

However, when it actually posts, Post Data on server side and inspection in developer tools is always

 {entries[]: 2342 etc}

Why are the square brackets appearing? How can I get rid of it?

Upvotes: 5

Views: 1819

Answers (1)

Kevin B
Kevin B

Reputation: 95022

The brackets are an indicator to the server for it to expect multiple similarly named parameters that should form an array or list. this is pretty standard, however, you can change the way it's done by setting the traditional setting to true. http://api.jquery.com/jquery.ajax

Upvotes: 2

Related Questions