Had an http/php/js application that was working.
For no reason I can see the application stopped working
get error XML Parsing Error: no root element foundLocation: file:///A.... (file location)
error line 37, column 3.
This is the end of the file.
<?php
ini_set("error_reporting",E_ALL);
ini_set("log_errors","1");
ini_set("error_log","php_errors.txt");
$conn=mysqli_connect("127.0.0.1","root","password","333_A2");
$town=$_GET["town"];
if($town=="all")
{
$query="select * from weather";
}
else
{
$query="select * from weather where `town` ='".$town."'";
}
$result = mysqli_query($conn,$query);
$jsonResult= array();
while($row=mysqli_fetch_assoc($result))
{
$jsonResult[]=$row;
}
mysqli_close($conn);
$jsonToGo = json_encode($jsonResult);
echo $jsonToGo;
?> (This is line 37)
In safari and Chrome returns readystate 4, status 0.
In firefox developer it returns readystate 4, status 4. but the response text is the above php file not the request.
I was working on some dom element construction that I did not think had caused the problem, but loaded a previous working version anyway. Still had the same problem.
Have stopped servers, shutdown and restarted computer.
this is the ajax request
function ajaxRequest(method, url, sync, data, callback){
var request = new XMLHttpRequest();
request.open(method,url,sync);
if(method == "POST"){
request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
}
request.onreadystatechange = function(){
if (request.readyState == 4) {
if (request.status == 200) {
var response = JSON.parse(this.responseText);
callback(response);
} else {
alert("AJAX REQUEST GONE BAD");
}
}
}
request.send(data);
}
have searched the net and am at a loss.
any help appreciated.
Kelly