我正在学习PHP和JS,并且在使用Ajax进行Get时,PH返回值是白色的。我正在转网,但没有找到任何东西,我需要一些帮助。
models = ["LinearRegression()"]
$idEvent = $_REQUEST["idEvent"];
$event = $this->model->getById($idEvent);
header('Content-type: application/json');
echo json_encode($event, JSON_PRETTY_PRINT);
exit;
ReferenceError:数据未定义
答案 0 :(得分:0)
首先将console.log()放在ajax调用中,如下所示:
$.ajax({
url: 'http://localhost/salgadar/public_html/Event/GetEventById',
type: 'get',
data: {
idEvent: idEvent
},
dataType: 'JSON',
success: function(data) {
alert('AJAX call was successful!');
console.log(data); //HERE CODE
$("#AjaxReturn").html(data);
},
error: function() {
alert('There was some error performing the AJAX call!');
}
});
然后告诉我出现了什么,我们将继续解决问题。