如何使用Jquery的Ajax在Codeigniter中检索和显示数据 [英] How to retrieve and display a data in Codeigniter with Jquery's Ajax
问题描述
如何使用Ajax在codeigniter中显示数据库中的数据?我正在寻找示例代码,但我找不到一些参考。
Hi,
How can I display a data from database in codeigniter using Ajax? I'm looking for sample codes but I cant find some reference.
$.ajax({
type: "POST",
url: "mainController/testForAjax",
data: $("#searchInput").val(),
success: function(){
console.log('Test result message of ajax')
}
});
我有这个代码,基本上我想要调用mainController的testForAjax方法。该方法调用数据库,然后将其发送回testForAjax以执行print_r()。
I have this code, basically I want to call the mainController's testForAjax method. That method calls a database, and then sends it back to testForAjax to do print_r().
推荐答案
.ajax({
类型: POST,
url: mainController / testForAjax,
data:
.ajax({ type: "POST", url: "mainController/testForAjax", data:
( #searchInput)。val(),
成功:功能( ){
console .log(' ajax'的测试结果消息)
}
});
("#searchInput").val(), success: function(){ console.log('Test result message of ajax') } });
I有这个代码,基本上我想调用mainController的testForAjax方法。该方法调用数据库,然后将其发送回testForAjax以执行print_r()。
I have this code, basically I want to call the mainController's testForAjax method. That method calls a database, and then sends it back to testForAjax to do print_r().
我现在得到它
I got it now
这篇关于如何使用Jquery的Ajax在Codeigniter中检索和显示数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!