jQuery - now: Creating an object and storing values in it to pass to an AJAX call
- by Josh K
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?