I want to send an array from my client jQuery code to my server PHP code. On the jQuery side, this is what I am doing:
$.ajax( {
url: someUrl,
data: {
action: 'opensearch',
search: query,
namespace: [10, 846],
suggest: ''
},
dataType: 'json',
});
On PHP's side:
echo $params['action'] ."\r\n";
echo $params['namespace'][0] ."\r\n";
echo $params['namespace'][1] ."\r\n";
The output of this is:
opensearch
0
So the parameters are sent correctly as I manage to print the string correctly. However the array appears not to sent correctly.
I have tried to use json_decode with and without the true option but to no avail.
Any suggestion is most welcome.