我有一个使用JS和PHP的基本内容交换程序。一切都很好,直到我注意到脚本在放置交换结果后回显了一个数字"1"。在我的html、php includes或脚本(我能找到(中没有第一个。它到底从哪里来,我怎么才能让它不出现。
JS-
function swapContent(cv){
$("#workwrap").html(loadgif.gif).show();
var url = "includescripts/swapscript.php";
$.post(url,{contentVar:cv},function(data){
$("#workwrap").html(data).show();
});
}
PHP脚本
<?php
$contentVar = $_POST['contentVar'];
if($contentVar == "logo"){
echo include("../workincludes/contA.php");
} else if($contentVar == "print"){
echo include("../workincludes/contB.php");
} else if($contentVar == "web"){
echo include("../workincludes/contC.php");
}
?>
HTML
<div id="content">
<div id="workwrap">
</div></div>
在include
call
之前删除echo
,成功时include
返回1
您不需要echo
包含
"1"是成功包含文件后的状态true
(解析为字符串(。
对于未来,如果您在结果中得到Ones或Zeores,请检查您是否尝试回显函数的结果。
包括手册:
Handling Returns: include returns FALSE on failure and raises a warning. Successful includes, unless overridden by the included file, return 1