I am trying to get a string from a text file. I have a php file called genjsonGPS.php that looks like this:
<?php
$myFile = "vesselGPS.txt";
$fh = fopen($myFile, 'r');
$vesselGPS = fread($fh, filesize($myFile));
fclose($fh);
echo("Hello");
?>
When I run it, I get for an output in my browser:
“Hello”
I have a webpage with a js file using microAjax (from the js file):
microAjax("genjsonGPS.php", function (res) {
alert (res);
});
When I run the webpage I get a blank alert. When I change the function above to:
microAjax("genjsonGPS.php", function (res) {
alert (res.toString);
});
I get an alert that says:
function toString() { [native code] }
How do I get the function above to output “Hello” in the alert like the browser does?
Please follow these tips.
Monitor your HTTP server’s access log, something like
tail -f /var/log/apache/access.logis helpful. (Assume you are working on *nix platform)If you are using Chrome, please check out the
networkmonitor panel.You’d better make sure that:
If you still cannot figure out where things goes wrong, if would be useful to let people know how
microAjaxis implemented.