introduction screenshots faq forum blog modules components download
Please use the search function and/or read the FAQ first.

Go to Topic: PreviousNext
Go to: Message ListNew TopicSearchLog InPrint View

Status value is always 0



Posted by: encore27
November 24, 2010 02:49AM
My EasyPHP installation always returns a readyState of 4 and a status value of 0. The responseText is an empty string. This occurs even on the simplest "Hello world" echo:
<?php
echo "Hello world";
?>
I used the default installation and have not changed any execution parameters.

Suggestions appreciated!

Dick
Options: ReplyQuote
Posted by: Amour
November 24, 2010 05:26AM
Please, can you explain what is that readystate ? Maybe an Ajax script ?
If yes, can you give us the full script, to test it ?
Options: ReplyQuote
Posted by: encore27
November 24, 2010 05:44PM
Here's the text for testAjax.html followed by the text for calc.php. Sorry it's so long. My results were obtained using Firefox:
-----------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
<script>
function getReq()
{
try {
var req = new XMLHttpRequest()
} catch(e1) {
try {
req = new ActiveXObject("Msxml2.XMLHTTP")
} catch(e2) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP")
} catch(e3) {
req = false
}
}
}
return req
}

//==============================================

function getValues(id)
{
var elem = document.getElementById(id);
return elem.value;
}

//==============================================

function calc()
{
var req = getReq();
if (!req) {
alert("Oops!");
return false;
}

var param = "";
param += ("lat1d=" + getValues("lat1d") + "&");
param += ("lat1m=" + getValues("lat1m"));

req.open("GET", "[localhost]; + param, true);

req.onreadystatechange = function()
{

if (this.readyState == 4) {
if (this.status == 200) {
if (this.responseText != null) {
alert("Got response");
info = this.responseText.split(",");
if (!info) { alert("No response text"); return;}
document.getElementById('init').innerHTML = info[0];
document.getElementById('dist').innerHTML = info[1];
}
else alert("No response text");
}
else alert("Ajax error: " + " " + this.readyState + " " + this.status + " " + this.responseText.length);
}
}

req.send();
}

//==================================================

function zero(id)
{
var elem = document.getElementById(id);
elem.value = 0;
}

//====================================================

function clear()
{
zero("lat1d");
zero("lat1m");

}

</script>

</head>
<body>
<font face="Arial">
<h1 align="center">The Great Circle Calculator</h1>
<form action="<script>calc();</script>" method="get">
<font face="Arial">
<table align="center">
<tr>
<td>&nbsp;</td>
<td align="center">DDD</td>
<td align="center">MM.M</td>
</tr>
<tr valign="middle">
<td><font color="#FF0000"><b>Lat 1</b></font></td>
<td><input id="lat1d" name="lat1d" size="5"></td>
<td><input id="lat1m" name="lat1m" size="8"></td>
</tr>
<tr>
<td align="center" colspan="8"><button type="button" onclick="calc();">Calculate</button></td>
</tr>
</table>
<br/><br/>
<table align="center">
<tr>
<td >Initial course</td>
<td id="init" name="init" width="30">&nbsp;</td>
<td >Distance</td>
<td id="dist" name="dist" width="30">&nbsp;</td>
</tr>
<tr valign "middle">
<td align="center" colspan="4">
<button type="reset" onclick="clear();">Reset</button>
</td>
</tr>
</table>
</font>
</form>
</font>
</body>
</html>
-------------------------------------------------------------
<?php
$hdl = fopen('c:\\web\\trace.txt', 'a');
fwrite($hdl, "Input rcvd\n");
if (isset($_GET["lat1d"]))
fprintf($hdl, "%d\n", $_GET["lat1d"]);
else
fwrite($hdl, "No post\n");
$lat1 = (int)$_GET["lat1d"] + (float)$_GET["lat1m"] / 60.0;
$lat2 = sprintf("%f", $lat1);
echo "$lat2,60";
fprintf($hdl, "%s\n", ob_get_contents());
fclose($hdl);
flush();
?>
Options: ReplyQuote
Posted by: encore27
November 24, 2010 05:56PM
Just tried Internet Explorer and Safari and it works as expected.
Options: ReplyQuote
Posted by: Amour
November 25, 2010 07:25AM
OK, so Thierry is right : it's browser specific, not on the webserver side...
Options: ReplyQuote
Posted by: encore27
November 25, 2010 09:16PM
It looks like the error occurred because I was loading the HTML as a file in Firefox instead of using localhost.

Thanks for your support!
Options: ReplyQuote
Posted by: Thierry
November 24, 2010 09:32AM
XMLRequest depends on your browser implementation. Check with Fifefox, I got intermediate readyState.

Nothing to do with EasyPHP.
Options: ReplyQuote


Go to: Message ListSearchLog In
Your Name: 
Your Email: 
Subject: 
Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.