If I replace in my controller function $this->request->is[‘ajax’] with $this->request->is[‘get’] and I send
/pricegroups/reorder?Pricegroup[0]=1&Pricegroup[1]=2&Pricegroup[2]=3&Pricegroup[3]=4
the controller function reorder works fine.
public function reorder() {
if ($this->request->is(['ajax'])) {
foreach ($this->request->query['Pricegroup'] as $key => $value) {
$pricegroup = $this->Pricegroups->get($value, [
'contain' => []
]);
$pricegroup->psort = $key;
$this->Pricegroups->save($pricegroup);
}
exit();
}
}
The js script in the Template/Pricegroups/index.ctp give me a right sortable list like this