Hello. I've got a webpage which needs to load some data from a database. In order to do that, I'm using jquery's $.post function, which loads a file called photoList.php, as follows:
*(photoList.php)*
<?php
include 'mysqlConnect.php';
$query = mysql_query("SELECT name FROM images");
$photoList = Array();
while ($row = mysql_fetch_assoc($query))
{
$photoList[] = $row['name'];
}
echo json_encode($photoList);
?>
*(jquery code which **is** being executed)*
$(document).ready(function(){
var photoList;
var photoCount;
$.getJSON("photoList.php", {}, processList);
function processList(data) {
photoList = data;
photoCount = photoList.length;
initialize();
}
});
*(this goes on and does some other stuff with initialize()).*
Through initialize() the data that is gotten from the database -image filenames- are supposed to be displayed in the webpage. Problem is: whenever I try it in my computer (apache, windows machine), everything works fine, images show up. When I upload my webhost (apache, linux machine), they don't, nothing shows up.
This is not the only part where it happens; I've got another, similar, code, in which I encode a javascript array to JSON and then, through ajax, send it to a php file which later decodes and uploads the data to the database. This, again, works in my computer but when I upload it, it doesn't.
I've tried checking in which part the code stops working and, at least in the last one, the array is encoded to json perfectly but then, when the php is supposed to get the data, the array shows up empty.
Any ideas? =/