jQuery - now: Creating an object and storing values in it to pass 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:30 UTC
Read the original article
Hit count: 194
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.
I need the request to be sent as a true POST request. I need to keep the php code simple because sometimes the login won't be an AJAX call.
I'm now trying the following with an error unexepected token ':'
myarr:
{
'name':'me'
}
The question has now become: How do I initialize a new javascript object as "blank", how do I set up mappings, and how do I pass it in an AJAX call?
© Stack Overflow or respective owner