Я просто хотел кое-что проверить здесь - нужно ли выводить значения в PHP, чтобы получить их через (jQuery) XHR?
например
PHP :
public function processRequest() {
//intercept AJAX requests
if (!empty($_GET)) {
if (isset($_GET['xhr'])) {
if ($_GET['xhr'] == true) {
//process AJAX
//call relevant method
echo json_encode(array('key' => 'value'));
return;
}
}
}
//else proceed with regular output
$this->render();
}
jQuery :
function doAjax(){
$.ajax({
url: "index.php?xhr=true",
cache: false,
dataType: 'json',
success: function(data){
console.log(data);
}
});
}
Этот журналобъект json в консоли Firebug с соответствующими значениями.Если я попытаюсь вернуть значение вместо эхо, я получу nada.