我需要在视图中显示从控制器返回的结果
这是我的ajax,
$(function () {
$(".branch").click(function () {
var branch_id = $(this).attr("alt");
$.ajax({
url: '<?php echo site_url('ajax_controller / getBranchDetails '); ?>',
type: 'post',
dataType: 'json',
data: {
branch_id: branch_id
},
success: function (result) {
//fetch result.data
alert(result.data);
}
})
})
})
嗨,你只需要在浏览器控制台显示你的ajax返回的数据。
$.ajax({
type: 'POST',
url: '<?php echo site_url('ajax_controller / getBranchDetails '); ?>',
data: {
branch_id: branch_id
},
dataType: 'json',
success: function(result){ console.log('result.data); }
});
,如果你不知道你的浏览器控制台在哪里,只需右键单击并选择inspect Element.