问题描述
我有一个ajax get脚本,无论我的数组大小如何,该脚本都可以在我的本地主机上完美运行。不幸的是,当我在Godaddy主机服务器上运行相同的脚本时,它返回一个EMPTY STRING作为响应。如果将我的php数组大小减小到几行,则可以使用。
我做了一些研究,并在此链接上应用了此修复程序... ajax GET failing when JSON content over 1MB on GoDaddy host ...但是我仍然得到相同的EMPTY STRING。任何建议将不胜感激。预先感谢。
到目前为止,这是我的代码...
PHP
function product_colors_data($ con){
$sql = mysqli_query($con,"SELECT * FROM `colors`");
$data = array();
while($row=mysqli_fetch_assoc($sql)) {
$data[] = $row;
}
return $data;
}
header(“ Content-Type:application / json”); 回声json_encode(product_colors_data($ con));
JQUERY
var row_num = $(“#table> tbody> tr”)。length;
$.ajax({
url: 'getcolors.php',dataType: 'json',timeout: 30000,data: {'row_num':row_num},// Setting the data attribute of ajax with file_data
type: 'GET',success: function(response) {
//alert(response);
console.log(response);
},error: function (xhr,status,error) {
console.log(xhr.responseText);
console.log(status);
console.log(error);
}
});
控制台日志
parsererror
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)