jQuery passing an array to an AJAX call

Posted by Josh K on Stack Overflow See other posts from Stack Overflow or by Josh K
Published on 2010-05-17T16:58:24Z Indexed on 2010/05/17 17:00 UTC
Read the original article Hit count: 135

Filed under:
|
|
|

I have an array:

myarr = [];

I'm filling it with some values:

myarray['name'] = "Me!";

Now I want to transform that array into a set of Key => Value pairs. I though jQuery would do it automatically, but it doesn't seem to.

$.ajax
({
    type: "POST",
    dataType: "text",
    url: "myurl",
    data: myarr
});

Is there a way to do this or something I'm doing wrong? I get no javascript errors, and no serverside errors other then no POST information at all.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about php