http500:服务器内部错误案例详解(服务器代码语法错误或者逻辑错误)
一、总结
服务器内部错误可能是服务器中代码运行的时候的语法错误或者逻辑错误
二、http500:服务器内部错误案例详解
只是一段在thinkphp5.0(php框架)中用jquery中的ajax中的post方法操作的案例
控制器代码:
//ajax评论点赞
public function commentLike(){
$data=input('post.');
$cid=$data['cid'];
$ans=db('comment')->where('cid',$cid)->setInc('click');
if(!ans) $this->error('点赞失败!!');
$clike=db('comment')->field('clike')->find($cid);
dump($clike);die;
}
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"></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是没有值的,所以这里是有错的
所以可以得到服务器内部错误可能是服务器中代码运行的时候的语法错误或者逻辑错误