我有这段代码:
public function deleteCharacter ($char_delete_id)
{
$deleteSuccess = Auth::user()->id == $delCharacterUserID?1:0;
return redirect('/characters')->with('deleteSuccess', $deleteSuccess);
}
如果我将它粘贴在模板中它工作正常,但如果我把它放在外部文件中,它不起作用。虽然外部文件中的所有其他javascript工作正常。我也试过这段代码:
document.addEventListener("keydown", keyDownTextField, false);
function keyDownTextField(e) {
var keyCode = e.keyCode;
if(keyCode==13) {
alert("You hit the enter key.");
} else {
alert("Oh no you didn't.");
}
}
但同样的故事。我做错了什么?