我尝试构建一个页面,因为客户端通过php js交互作为休闲登录
$hold = ("< button onclick = `
function myFunction(){
alert('works!');
}
myFunction();
` >My balance</button>");
echo hold;
然后我想通过js
将dinamicly发送到htmlvar Permition = localStorage.getItem("Permition");
$.post('MenuConstructor.php',
{
Permition:Permition
},
function(data){
menu = data;
//alert(data);
document.getElementById("div").innerHTML = menu;
}
);
但是对于一些共鸣,警报不起作用你们有什么建议吗? 有时我得到错误未定义有时我得到错误&#34;未终止模板文字&#34;
答案 0 :(得分:0)
"Unterminated template literal"
:) You need escape illegal character.
<div onclick="alert("123")">
<div onclick="alert("123")"> // php htmlspecialchars (maybe) (single ' is ') quot with no "e" at it's end
$url = 'index.html?a='.urlescape($value);
echo '<a href="'.htmlspecialchars($url).'"></a>'