【发布时间】:2019-12-06 08:31:21
【问题描述】:
ajax 请求中的内部服务器错误我的函数在 localhost 中正常工作,但在 cpanel 中返回错误 500
var MainRoot = 'http://localhost/sjkala/admin/';
function NumberToPersianWord(price_area,num)
{
var price=document.getElementById(num).value;
var finalprice =parseFloat(price.replace(/,/g, ''));
if(finalprice > 0)
{
$.ajax({
url:MainRoot+'NumberToPersianWord',
type:"POST",
data:'price='+finalprice,
success:function(data)
{
$("#"+price_area).html(data);
}
});
}else{
return false;
}
};
和php代码
public function NumberToPersianWord()
{
$int=gmp_init(Request::get('price'));
$price=gmp_strval($int);
if(is_numeric($price))
{
if(strlen($price) > 1)
{
$final= substr($price, 0, -1);
$final=$price;
}else{
$final=$price;
}
$num=new numToWord_Fa();
print $num->numberToWords($final)." تومان ";
}else{
$bad=url('BadRequest');
header('Location:'.$bad);
}
}
在 locahost 中工作完美,但在 cpanel 中返回错误 500
【问题讨论】:
-
比较
php -i从 CLI 安装的模块/扩展或创建一个执行phpinfo()的简单脚本。也尝试匹配 Apache2/nginx 配置。最简单的方法是检查日志文件是否有错误。 -
正如 Markus 所说,首先请检查您的服务器上是否安装了正确的 PHP 版本。
-
首先检查错误日志,找出错误的真正原因。
-
从
MainRoot中删除http://localhost/后尝试。 -
在 error_log CPANEL :: 调用未定义函数 gmp_init();我的 PHPVERSION ::: 5.6
标签: php ajax internal-server-error