[编辑] 我有以下链接:
<a href="" class="undo_feedback">Undo</a>
我在点击链接时执行 ajax 请求:
$('table').on('click', '.undo_feedback', function(e){
// some code here
$.ajax({
type: "POST",
data: {'_method': 'delete'},
url: //some url
});
e.preventDefault();
});
它给出错误 cannot GET '//some url'
。 POST 请求执行成功。我怎样才能摆脱这个错误?
我试过使用 return false
、e.stopPropagation()
和 e.stopImmediatePropagation()
但它们似乎都不起作用。任何帮助将非常感激。提前致谢:)
最佳答案
$('table').on('click', '.undo_feedback', function(e){
// some code here
e.preventDefault();
$.ajax({
type: "POST",
method : "delete",
url: //some url
});
});
把e.preventDefault();
放在上面
希望对你有帮助
关于javascript - 不要在点击链接时发送 GET 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22528470/