【发布时间】:2019-09-18 13:31:15
【问题描述】:
我有一个现成的 ci 应用程序,我正在尝试使用 ajax,但即使我尝试了许多正确的代码,get 也可以工作,但帖子从来没有我认为配置有问题 ajax_test 视图
<script src="https://code.jquery.com/jquery-3.4.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
var base_url = "<?=base_url()?>";
$(document).ready (function(){
$('#get_bt').click(function(){
$.post(base_url+'ajax_test/info_page' , {name:'bashir' , id:'1'}, function(data){
alert(data);
})
});
});
<button id="get_bt">get</button>
控制器
<?php
class Ajax_test extends CI_Controller {
public function index(){
$this->load->helper('url');
$this->load->view("ajax_test");
}
public function info_page(){
echo $this->input->post('name');
}
}
?>
请注意,它适用于 get 而不是 post jquery 错误
加载资源失败:服务器响应状态为 403 (Forbidden)
【问题讨论】:
-
检查你的网址,因为它在我这边工作正常。
标签: php jquery codeigniter