I have an ajax get script which works perfectly on my localhost irrespective of my array size. Unfortunately when I run the same script on Godaddy host server it returns an EMPTY STRING as the response. If a reduce my php array size to a few rows it works.
I did a little research and applied the fix on this link... ajax GET failing when JSON content over 1MB on GoDaddy host ...but I'm still getting the same EMPTY STRING. Any suggestions will be greatly appreciated. Thanks in advance.
Here is my code so far...
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"); echo 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);
}
});
CONSOLE LOGS
parsererror
I found an alternative to my problem. It might not be ideal but it gets the job done. I converted 'colors' table to a json file and continued from there. Here is my code...