Hello all. I have AJAX call:
function showResponse(responseText, statusText, xhr, form) {
console.log(responseText);
console.log(statusText);
console.log(JSON.stringify(xhr));
}
$('form#saveConfig').on('submit', function() {
var post = $.post('submitForm', {
someData
}, showResponse);
post.error(function(data) {
console.log('Error: ' + JSON.stringify(data));
});
});
And I have echo in controller:
public function submitForm() {
$this->view->disable();
echo json_encode('Ok');
die;
}
Controller getting data from POST, but AJAX doesn't receive answer from controller. Why?
I'm using MicroMVC.
EDIT: When I was used:
public function submitForm() {
$this->response->setJsonContent('Hello')->send();
}
in browser all ok, but AJAX doesn't receive Hello
string
P.S. Sorry for my bad English =(