1
我当前使用的笨,我想菜单 上创建通知在控制器如何使用codeigniter将数据传递到ajax?
class Notes extends Frontend_controller{
public function __construct() {
parent::__construct();
}
public function index(){
$this->data['data'] = array(
'fuck'=>'fuck',
'fucks'=>'fuckf',
'fuckf'=>'fucks',
);
$this->load->view('templates/notification/notification',$this->data);
}
}
这里是我的回波数据查看 在View
<li>
<?PHP foreach($data as $data){
echo $data;
} ?>
</li>
最后我jQuery的AJAX调用
<script>
$(function() {
var data = document.getElementsByTagName("li").val();
$.ajax({
type: "POST",
url: "<?PHP echo base_url("/notes/notes") ?>",
data: data,
contentType: 'application/json; charset=utf-8',
dataType: 'html',
async: true,
cache: false,
success: function(res) {
$("#notes").html(res);
}
});
return false;
});
</script>
结果我收到如下错误
我怎会现在请帮 未捕获的ReferenceError:$没有定义
我已经加载它 – hengsopheak 2014-11-09 06:34:48
哦,你是对的,因为我把Ajax调用下面的jQuery库调用谢谢 – hengsopheak 2014-11-09 06:43:27