fix: Updated the new ajax methods to follow the new JSON rules

pull/2489/head
iglocska 2017-08-10 14:12:47 +02:00
parent ead2b9e1fd
commit 5d9cfe5d6c
2 changed files with 14 additions and 11 deletions

View File

@ -93,14 +93,14 @@ class ObjectReferencesController extends AppController {
'conditions' => array('ObjectReference' => $this->ObjectReference->id)
));
return $this->RestResponse->viewData($object, $this->response->type());
} else {
return new CakeResponse(array('body'=> json_encode(array('saved' => true, 'success' => 'Object reference added.')),'status'=>200));
} else if ($this->request->is('ajax')) {
return new CakeResponse(array('body'=> json_encode(array('saved' => true, 'success' => 'Object reference added.')),'status'=>200, 'type' => 'json'));
}
} else {
if ($this->_isRest()) {
return $this->RestResponse->saveFailResponse('ObjectReferences', 'add', false, $this->ObjectReference->validationErrors, $this->response->type());
} else if ($this->request->is('ajax')) {
return new CakeResponse(array('body'=> json_encode(array('saved' => false, 'errors' => 'Object reference could not be added.')),'status'=>200));
return new CakeResponse(array('body'=> json_encode(array('saved' => false, 'errors' => 'Object reference could not be added.')),'status'=>200, 'type' => 'json'));
}
}
} else {

View File

@ -262,7 +262,8 @@ class ObjectsController extends AppController {
'success' => $message
)
),
'status'=>200
'status'=>200,
'type' => 'json'
)
);
} else if ($this->_isRest()) {
@ -281,13 +282,15 @@ class ObjectsController extends AppController {
if ($this->request->is('ajax')) {
return new CakeResponse(
array(
'body'=> json_encode(
array(
'saved' => false,
'errors' => $message
)
),
'status'=>200)
'body'=> json_encode(
array(
'saved' => false,
'errors' => $message
)
),
'status'=>200,
'type' => 'json'
)
);
} else if ($this->_isRest()) {
return $this->RestResponse->saveFailResponse(