我知道以前曾有人问过这个问题,但我已经回顾了我可以找到的所有以前的帖子,但仍然无法使它正常工作。希望这个问题很简单,你们可以帮助我解决。
我无法从PHP脚本获取返回数组,并将其进行json_encoded转换为Javascript数组。如果删除dataType应该为json的条件,则成功函数将抱怨意外数据。
我有一个Javascript函数,该函数使用POST方法调用PHP脚本。在PHP脚本中,我将一些调试消息写入日志文件,并显示json_encoded数组的内容。当我检查使用JSONLint的内容是否符合JSON要求,但我的JavaScript函数始终出错。
PHP函数如下所示:
<?php
// Include the php logger class so that we can write log messages to a log file
require_once('/myscripts/phplogger.php');
// Set up php log file
$log = new Logging();
$log->lfile('/mylogfiles/php-debug.log');
// Log status
$log->lwrite('Starting debug');
// ...
// (there's some more stuff here to get the data from a MySQL database)
// ...
// The following line when read in the log file shows a valid JSON array
$log->lwrite('array '.json_encode($dataVnvMethods));
$json_dataVnvMethods = json_encode($dataVnvMethods);
$log->lwrite('Ending debug');
?> …Run Code Online (Sandbox Code Playgroud) 使用xampp并遇到一些问题.当我将一段php代码放入自己的php扩展文件并通过localhost运行时,它就可以了.当我将php嵌入到具有html扩展名的文件中并运行时,似乎php没有被解释但完全被忽略.是否有一个xampp配置选项,禁用在javascript或html文件中解释的PHP?
任何人都可以帮我调试这个问题吗?这是我想从cron运行的php脚本的一部分.我一直在看它,但无法弄清楚出了什么问题.以下行抛出PHP错误"PHP Parse错误:语法错误,意外的T_LNUMBER在......行..."
$sqlreadstmt = $db->query("
select distinct
rsdata.rs_variant,
rsdata.weeknumber,
rsdata.rs_moduleid,
rsdata.rs_objectidentifier,
trdata.tr_objectidentifier,
trdata.tr_testversion,
trdata.tr_plannedgate,
trdata.tr_vnvmethod,
testatussequence.tesequencenr,
trdata.tr_testexecutionstatus
from rsdata,trdata,module,variantgates,testatussequence
where rsdata.weeknumber="1339"
and rsdata.rs_moduleid = module.moduleid
and rsdata.weeknumber = trdata.weeknumber
and rsdata.rs_reviewstatus != "Obsolete"
and rsdata.rs_reviewstatus != "Rejected"
and rsdata.rs_introbjectidentifieralllevels != ""
and rsdata.rs_introbjectidentifieralllevels != "Unknown"
and find_in_set(trdata.tr_objectidentifier, (select rsdata.rs_introbjectidentifieralllevels))
and trdata.tr_plannedgate != ""
and trdata.tr_plannedgate != "Unknown"
and trdata.tr_plannedgate = variantgates.gate
and trdata.tr_variant = variantgates.variant
and trdata.tr_testexecutionstatus = testatussequence.testatus
order by
rs_variant ASC,
weeknumber ASC,
rs_moduleid ASC,
rs_objectidentifier ASC,
tr_testversion …Run Code Online (Sandbox Code Playgroud)