$request_id = $_POST['id']; // Nota Bene!!!! php needs an array here and javascript is passing it an object. // et VOILA!! the whole problem disappears if you just typecase the object as an array :) // ... welcome to the new world, sir - switch ($request_function) { case 'add_background': $background_object = new Background(); $array_of_fields = (array) json_decode($request_json); // remove the db_id (first) item in the array since we're adding a new one to the database table array_shift($array_of_fields); $background_object->add($array_of_fields); echo 'OK'; break; case 'get_background': $background_object = new Background(); $return_boolean = $background_object->get($request_id); if ($return_boolean) { echo json_encode($background_object->data()); } else { echo 'Error getting background with id =' . $request_id; } break; case 'get_background_list': $background_object = new Background(); $return_boolean = $background_object->getNameList(); if ($return_boolean) { echo json_encode($background_object->data()); } else { echo 'Error getting background name list'; } break;