POST array data with javascript

Viewed 46903

I'm trying to post some data to a http connector but cant figure out how i can post Array data...

My data Looks like that:

var data = [{ 
    key:'myKey',
    keyName:'myKeyName',
    value:'value',
    valueName:'valueName' 
}, { 
    key:'mySecondKey', 
    keyName:'mySecondKeyName',
    value:'secondValue',
    valueName:'secondValueName'
}, ...and so on ];

I try to post it via Ajax like this:

$.ajax({
    type:   "POST",
    url:    url,
    data:   data,
    error:  function(){
        alert("Error");
    },
    success: function(){
        alert("OK");
    }
});

The request Returns ok but when i look at the request data it Posts undefined=value&undefined=secondValue

How can i solve this? I Need to save all those informations for configurations

A simple post with just some keys and values like key=value&key2=value2 works like a charm.

1 Answers
Related