Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php javascript ajax字符串错误_Php_Javascript_Ajax_String - Fatal编程技术网

php javascript ajax字符串错误

php javascript ajax字符串错误,php,javascript,ajax,string,Php,Javascript,Ajax,String,我正在php脚本中构建一些html,以便通过Ajax将其发送回页面 $other_content = Model_Db::dbSelect($query); $div_center .= "<table>"; for($i = 0;$i<sizeof($other_content);$i++) { $div_center .= "<tr>"; $div_center .= "<

我正在php脚本中构建一些html,以便通过Ajax将其发送回页面

$other_content = Model_Db::dbSelect($query);

        $div_center .= "<table>";
        for($i = 0;$i<sizeof($other_content);$i++) {
            $div_center .= "<tr>";

            $div_center .= "<td><a href='#' onclick='changediv('test','0')'>".$other_content[$i]->content_name."</a></td>";
            $temp = "<td><a href='#' onclick='changediv('test','0')'>".$other_content[$i]->content_name."</a></td>";
            die($temp);

            $div_center .= "</tr>";
        }
        $div_center .= "</table>";
$other\u content=Model\u Db::dbSelect($query);
$div_中心=“”;

对于($i=0;$i我建议您将引号字符转义

$temp = "<td><a href=\"#\" onclick=\"changediv('test', '0')\">" . 
$other_content[$i]->content_name. "</a></td>";
$temp=”“;

“\”在字符串中转义双引号

您将单引号的函数解释为双引号弄乱了:

yours <a href='#' onclick='changediv('test','0')'>

func  <a href="#" onclick="changediv(" test','0')'="">
你的
func
它假定(在%signs之间)%test','0')'=“”%是标记的参数,请尝试用双引号替换单引号,并使其符合html/xhtml:

<a href="#" onclick="changediv('test','0')">

因此,单引号和双引号将被正确设置


你也必须更改PHP引号

你确定你发布了你真正得到的东西吗?如果我们能看到“真实的”“输出——在这里,您在代码中使用单引号,并且您说您得到了双引号;是真的吗,还是只是你没有复制粘贴实际输出?它实际上在单引号之间,我得到了双引号。。。非常奇怪!它起作用了,但我还是不明白为什么不转义引号会加上“”。。。。无论如何,谢谢你的帮助!