Im using ajax:
$.ajax({
url: 'testURL',
type: 'POST',
dataType: 'json',
data: {userId: userIds, imageUrl: imageUrl, message: message },
success: callBack
});
and server side:
$data = $this->_request->getPost();
$response = Zend_Json::decode($data, true);
But Im getting an error on server side:
Decoding failed
What am i doiung wrong ?
Thanks for any help
EDIT:
Ive tried that:
$.ajax({
url: STValentines.baseUrl+'/mensaje/sendmessage',
type: 'POST',
dataType: 'json',
data: {userId: '111', imageUrl: 'imageurl', message: 'message' },
success: callBack
});
the same error
EDIT 2:
Here is once again js code php code and the result :(
$.ajax({
url: 'testURL',
type: 'POST',
dataType: 'json',
data: "{'userId': 'test1234', 'imageUrl': 'testimageUrl', 'message': 'testmessage' }",
success: callBack
});
public function sendmessageAction() {
$data = $this->_request->getPost();
print_r($data);
$response = $data;
$this->_helper->json($response);
RESULT:
Array
(
)
$data
actually contain a JSON string? Does PHP's nativejson_decode()
work? Are there multibyte/non-ascii characters in the JSON string? – Carpetsmoker Feb 1 '12 at 21:31{"userId": "111", "imageUrl": "imageurl", "message": "message" }
to be a suitable test. – Crashspeeder Feb 1 '12 at 22:19