我有下面的代码,我看不到输出,但是当我在萤火虫中看到时,我可以看到输出……但在 html 表中看不到。
[View]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="<?php echo base_url();?>js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>js/general.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<input type="submit" name="getdata" id="getdata" value="Submit"/>
<div id="result_table">
</div>
</body>
</html>
控制器
class Ajax1 extends CI_Controller {
private $limit = 30;
private $offset = 4;
function __construct()
{
parent::__construct();
$this->load->model('User_model','',TRUE);
$this->load->model('Person_model','',TRUE);
}
public function index()
{
$this->load->view('ajax1');
}
public function get_all_users() {
$this->output->set_content_type('text/javascript; charset=UTF-8');
$query = $this->Person_model->get_paged_list(10, 0)->result();
$text = "Hi,testing";
$this->load->view('ajax1');
echo json_encode($query);
}
}
?>
AJax // JavaScript 文档
$(document).ready(function(){
$('#getdata').click(function(){
$.ajax({
url: "http://localhost/wizaptech/index.php/ajax1/get_all_users",
type:'POST',
dataType: 'json',
success: function(output_string){
$("#result_table").append(output_string);
} // End of success function of ajax form
}); // End of ajax call
});
});
所以任何人都可以告诉我我错过了什么......
我已经包含了ajax代码