I would like to send data using $.ajax like this:
$.ajax({'url': 'my.php',
'type': 'POST',
'data': arr,
'success': function(response) {
alert(response);
}
});
The problem is that arr
is an associative array that looks like:
arr['description_0'] = 'very nice picture!';
arr['tags_0'] = 'David "Nice Picture" 2010';
arr['description_1'] = 'In the pool';
arr['tags_1'] = '"April 2010" Australia';
. .
. .
. .
If my.php
looks like:
<?php
echo count($_POST);
?>
The response
is 0.
But, if I change
'data': arr,
to
'data': 'a=chess&b=checkers',
the response
is 2, as expected.
What should I convert arr
to so that the data will be sent properly ?