I have a strange problem, when I send data in POST with AJAX in JQuery to query SQL in php and push the data in array, the server return 500 error.
This the php file :
require_once 'db_connect.php';
$objConn=new ConnectionDB();
$connection=$objConn->ConnecteDB();
header('Content-Type: text/plain');
$dataRetourn=$_POST["test"];
$debut=$_POST['debut'];
$fin=$_POST['fin'];
$proute=array();
$i=0;
$i=0;
foreach ($dataRetourn as $data){
$imei = $data["aniImei"];
$requete="SELECT latitude, longitude, dateHeure
FROM anilog
WHERE anilog.imei='$imei' and dateHeure BETWEEN '$debut' AND
'$fin'
ORDER BY dateHeure ASC";
$resultat1=mysqli_query($connection,$requete);
while($donnees=mysqli_fetch_assoc($resultat1)){
$dataRetourn[$i]["path"][]=$donnees;
}
$i=$i+1;
}
echo json_encode($dataRetourn);
mysql_close($connection);
My query AJAX :
var options = {
url: "js/controller/getParcours.php",
dataType: "text",
type: "POST",
data: { test: parcours, debut : datep.debut, fin: datep.fin}
};
$.ajax(options).done(function(data){console.log(JSON.parse(data));});
PS: the PHP version on the server is the 5.3
And the variable parcours in query AJAX is $dataretourn in php script and it's an array of object
A HTTP 500 error code always means there is something wrong with your serverside code, your case being your PHP script. This may either be a syntax error or a bug.
You should be able to find more information in your server log, if you are using nginx this would be /var/log/nginx/error.log
and if you are using apache, this would be /var/log/apache2/error.log
(unless otherwise specified in your VirtualHost/site configuration).
However it is highly discouraged to use PHP 5.3 since it is deprecated , more information here: PHP version lifetime
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.