codeIgniter / jQuery的 - Ajax调用返回我的回声完整的HTML页面,而不是 [英] CodeIgniter/jQuery - Ajax call returns full html page instead of my echo
本文介绍了codeIgniter / jQuery的 - Ajax调用返回我的回声完整的HTML页面,而不是的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我看来,我有一个Ajax调用:
In my view I have an ajax call:
$(".previous").click(function() {
$.ajax({
type: "POST",
url: "planner/get_cal",
data: {current_month: current_month},
success: function(msg){
alert(msg);
}
});
在我的规划控制器get_cal功能:
the get_cal function in my Planner controller:
function get_cal()
{
echo "dinosaurs";
}
不过,而不是返回恐龙,它返回一个完整的HTML页面。我想不通为什么。思考?非常感谢。
However, instead of returning "dinosaurs", it returns a full HTML page. I can't figure out why. Thoughts? Thanks a lot.
推荐答案
我通过使用斜线作为在评论我的问题建议的解决了这一点。
I solved this by using a leading slash as suggested in the comments to my question.
$.ajax({
type: "POST",
url: "/planner/get_cal",
dataType: "text",
data: {current_month: current_month},
success: function(msg){
alert(msg);
}
});
这篇关于codeIgniter / jQuery的 - Ajax调用返回我的回声完整的HTML页面,而不是的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文