tags:

views:

51

answers:

2

Hello, how can I create map to send it like post-data, using ajax? For exmaple, I has an iterator each function, where I should do something like:

var map = [];
...each(function() {
map[ $(this).key() ] = $(this).val();
});

Or what another synax?

A: 

If you are trying to submit form data through ajax, take a look at serialize()

Corey Downie
A: 

You would essentially be mimicking jQuery's serialize() function:

var serialized = [], str;
$.each('#youritem', function(key, val) {
    serialized.push(encodeURIComponent(key) + '=' + encodeURIComponent(val));
}); 

// will contain your $_GET string
str = serialized.join('&')
cballou