在POST在Opera jQuery的语法错误语法错误、POST、Opera、jQuery

2023-09-11 01:20:38 作者:醉逍遥

我有一个连接到一个按钮的onClick事件一点点的JavaScript功能。它似乎在Firefox(3.0.4)完美地工作,但都歌剧(9.62)和IE浏览器无法从同一个.js文件执行任何其他JS,包括哪些正常工作。下面的函数是罪魁祸首:

I have a little javascript function which is attached to an onClick event of a button. It appears to work perfectly in Firefox(3.0.4), but both Opera(9.62) and IE fails to execute any other JS from the same .js file, including what normally works. The following function is the culprit:

function deleteComment(id){
   $.post("ajax/comments.php", {delete: id},
      function (reply) {
         if (reply == "true") {
            alert("Comment deleted!");
         }
      }
   );   
}

歌剧院dev的控制台说,有一个在第二行有语法错误,它需要一个代替第一'{'的'}'。我认为它是IE浏览器同样的问题。这是jQuery的失败走好的IE浏览器和Opera JS实现照顾或者是我的code故障在某种意义上?我有正常工作的文件中一个类似的职位jQuery的功能(当上述code是不存在的)。

The Opera dev console says that there is a syntax error in the second line and that it expects a '}' in place of the first '{'. I assume it is the same problem for IE. Is this jQuery that fails to properly take care of the IE and Opera JS implementations or is my code faulty in some sense? I have a similar POST jQuery function in the file which works fine (when the above code is not there).

推荐答案

尝试把双引号中的字删除。我曾经有一个问题的钥匙需要是字符串,因为一些浏览器未接他们。

Try putting the word delete in double quotes. I once had a problem with the keys needing to be strings because some browser wasn't picking them up.