Renyi-Fan

http500:服务器内部错误案例详解(服务器代码语法错误或者逻辑错误)

一、总结

服务器内部错误可能是服务器中代码运行的时候的语法错误或者逻辑错误 

 

二、http500:服务器内部错误案例详解

只是一段在thinkphp5.0(php框架)中用jquery中的ajax中的post方法操作的案例

控制器代码:

1 //ajax评论点赞
2 public function commentLike(){
3     $data=input(\'post.\');
4     $cid=$data[\'cid\'];
5     $ans=db(\'comment\')->where(\'cid\',$cid)->setInc(\'click\');
6     if(!ans) $this->error(\'点赞失败!!\');
7     $clike=db(\'comment\')->field(\'clike\')->find($cid);
8     dump($clike);die;
9 }

jquery代码

<script >
  $(document).ready(function(){
    $(".clike").click(function(){
      // alert(\'点赞成功!\');
        $.post("{:url(\'engage/commentLike\')}",
        {
          cid:$(this).attr(\'value\')
        },
        function(data,status){
          alert("Data: " + data + "\nStatus: " + status);
        });
      });
    });
</script>

html代码

<span class="clike" value="{$vo.cid}"><i class="iconfont">&#xe631;</i>{$vo.clike}</span><span>回复</span>

点点赞按钮的时候发生http500:服务器内部错误

 

错误

jquery.min.js:4 POST http://www.drsong.com/index.php/student/engage/commentlike.html 500 (Internal Server Error)

 

三、问题解析

服务器内部错误,说明和页面端应该关系不大

加检验代码

这样的代码也会报同意的http500的服务器内部错误,而且dump($ans);换成dump($cid);就不报错误了。

从php角度来说,这个代码是有错的,dump $ans的时候ans是没有值的,所以这里是有错的

所以可以得到服务器内部错误可能是服务器中代码运行的时候的语法错误或者逻辑错误

 

分类:

技术点:

相关文章: