I have problem to parse a get variable which contains an array and send it with jquery ajax.
the array what I send can look as it follows
ids%5B%5D 1403172219
ids%5B%5D 1530542001
ids%5B%5D 1582588379
but when I try to dump($_GET['ids]
) I get null I dumb the hole $_GET
than looks like
ids%5B%5D] => 1530542001
JQuery
function update_category(selected) {
console.log(cids);
$.ajax({
url: '/admin/',
type: 'GET',
dataType: "application/JSON",
data: {
ids: cids,
s_category: selected,
controller: 'products',
traditional: true,
action: 'update_category'
},
success: function(data) {
addAlert('alert-'+data, data);
},
error: function(data) {
addAlert('alert-'+data.responseText, data.responseText);
}
});
controller
protected function update_category() {
print_r($_GET);
$cat_ids = $_GET['ids'];
$category = $_GET['s_category'];
if(!empty($cat_ids) && !empty($category)){
$this->model->updateCategory($cat_ids, $category);
} else {
echo 'Fähler in der Daten übergabe!';
exit();
}
}
}
on localhost I use PHP 5.4 and I do not face any problems on live Server ubuntu PHP 5.3.10 the error persist
the correct output on localhost
Array (
[ids] => Array (
[0] => B6Q09EA#ABD
[1] => H4P04EA#ABD
)
[s_category] => 4
[controller] => products
[traditional] => true
[action] => update_category
)
ids are builded like
cids = [];
jQuery.each(sData, function(key, value) {
cids.push(value.value);
});