我正在尝试从文本文件中获取字符串。我有一个名为 genjsonGPS.php 的 php 文件,如下所示:
<?php
$myFile = "vesselGPS.txt";
$fh = fopen($myFile, 'r');
$vesselGPS = fread($fh, filesize($myFile));
fclose($fh);
echo("Hello");
?>
当我运行它时,我会在浏览器中得到一个输出:
“你好”
我有一个带有使用 microAjax 的 js 文件的网页(来自 js 文件):
microAjax("genjsonGPS.php", function (res) {
alert (res);
});
当我运行网页时,我得到一个空白警报。当我将上面的功能更改为:
microAjax("genjsonGPS.php", function (res) {
alert (res.toString);
});
我收到一条警报,上面写着: function toString() { [native code] }
如何让上面的函数像浏览器一样在警报中输出“Hello”?