我在做ajax call。而且每次发生500 Internal server error都会失败。但是客户端代码中没有错误。
JavaScript代码:
$.ajax({
url:"test.php",
type:"POST",
dataType:"html",
data:{
userInput:userInput /* userInput is some text value */
}
});PHP代码:
<?php
$con=mysqli_connect("localhost","root","password","test");
$user_data=$_POST['userInput'];
echo $user_data;
?>每当我在控制台中看到这些错误代码时:
POST XHR http://localhost/test.php和[HTTP/1.0 500 Internal Server Error 1ms]
问我你是否需要更多的信息。
NB:我在这个社区里发现了很多问题。所有这些都没有解决我的问题,。
发布于 2015-09-29 16:39:41
我认为内部服务器错误是由于未启用mysqli扩展的mysqli_connect函数调用造成的。尝试phpifo()以验证mysqli扩展已启用
发布于 2015-09-29 16:30:32
您可以捕获执行回调时的错误。示例:
$.ajax({
url:"test.php",
type:"POST",
dataType:"html",
data:{
userInput:userInput /* userInput is some text value */
}
}).success(function() {
window.alert('Ajax completed successfully');
}).error(function() {
window.alert('An error has occurred');
});https://stackoverflow.com/questions/32849013
复制相似问题