jquery post返回渲染的html页面而不是sql结果 [英] jquery post returning rendered html page rather than sql result

查看:678
本文介绍了jquery post返回渲染的html页面而不是sql结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中使用codeigniter并且有一个完美运行的jquery post函数。

I am using codeigniter in my application and have a jquery post function that works perfectly.

$.post('getticketstacktype', {ticketnumber:ticketnumber},function(result) {
alert(result);
}

然后我在另一个编辑页面上使用完全相同的post函数。这个页面预先填充了PHP并且工作正常。

I am then using the exact same post function on another edit page. this page is prepopulated with PHP and works correctly.

我使用相同的帖子为了调用我的控制器,我检查了票号是否正确

I use the same post to call my controller, I have checked that ticketnumber value is correct

$.post('getticketstacktype', {ticketnumber:ticketnumber},function(result) {
alert(result);
}

它调用的控制器函数是:

the controller function it calls is:

function getticketstacktype(){    
    if (isset($_POST['ticketnumber'])){
        $ticketnumber = $_POST['ticketnumber'];            
        $data = $this->wos_model->getticketstacktype($ticketnumber);
        $this->output->set_content_type('application/json')->set_output(json_encode($data));
        }
    }

现在这种情况正常,结果为'7'但相反,在我的编辑页面上,它返回我呈现的整个视图页面:
所以< html>< head> ......< / html>线条徘徊)

now where this works correctly the result is '7' but instead, on my edit page it is returning my entire view page rendered: so <html><head>......</html> hundereds of lines)

我无法弄清楚为什么我的整个页面在结束时被返回到jquery帖子另一种观点。

I cant figure out my why my entire page is being returned as a result to a jquery post when it is working in another view.

我还验证了两个观点的帖子信息与firebug相同。

I have also verified that the post information from both views is the same with firebug.

任何建议?
一如既往地谢谢。

Any advice? Thanks as always.

推荐答案

这通常发生在后端发生致命错误时。当PHP上发生致命错误时,它会构造一个页面以显示包含在框中的一些错误消息。 jQuery尝试解释为有意义的数据但它失败了。如果您在Firebug或Google Chrome Dev工具中看到此回复,您实际上可以看到该页面可以呈现。

This usually happens when a fatal error occurred in the backend. When a fatal error occurs on PHP, it constructs a page to displays some error message contained within a box. jQuery tries to interpret to a meaningful data but it fails. And if you see this response in Firebug or Google Chrome Dev tool you can actually see that the page can be rendered.


  1. 使用Firebug或谷歌Chrome开发工具,用于追踪从服务器发回的结果

  2. 确保后端没有错误

这篇关于jquery post返回渲染的html页面而不是sql结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆