php javascript ajax字符串错误
我正在php脚本中构建一些html,以便通过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 .= "<
$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引号你确定你发布了你真正得到的东西吗?如果我们能看到“真实的”“输出——在这里,您在代码中使用单引号,并且您说您得到了双引号;是真的吗,还是只是你没有复制粘贴实际输出?它实际上在单引号之间,我得到了双引号。。。非常奇怪!它起作用了,但我还是不明白为什么不转义引号会加上“”。。。。无论如何,谢谢你的帮助!