I have a problem with my AJAX request here. I am displaying data through a foreach loop creating delete buttons for each entry. The first time I click on one of these button the entry is being deleted properly, but then the second click on the next element fails.
这里我的AJAX请求有问题。我通过foreach循环显示数据,为每个条目创建删除按钮。我第一次单击其中一个按钮时正在正确删除该条目,但第二次单击下一个元素失败。
<?php foreach ($notes as $note): ?>
...
<script type="text/javascript">
$(document).ready(function () {
$("<?php echo '#NoteDeleteButton' . $note['Note']['id']>").bind("click", function () {
$.ajax({async: true,
dataType: "html", success: function (data) {
$("#NoteUpdateSection").html(data);
}, type: "POST", url: "<?php if($this->base != '') { echo '' . $this->base; } ?>\/notes\/delete\/<?php echo $note['Note']['id'] ?>\/<?php echo $current_controller ?>\/<?php echo $current_id ?>"});
return false;
});
});
</script>
...
<?php endforeach; ?>
In my browsers console I get this error after clicking the delete button the first time:
在我的浏览器控制台中,第一次单击删除按钮后出现此错误:
Uncaught SyntaxError:
Unexpected identifier jquery.min.js?1406620464:2
(anonymous function) jquery.min.js?1406620464:2
n.extend.globalEval jquery.min.js?1406620464:2
n.fn.extend.domManip jquery.min.js?1406620464:3
n.fn.extend.append jquery.min.js?1406620464:3
(anonymous function) jquery.min.js?1406620464:3
n.access jquery.min.js?1406620464:3
n.fn.extend.html jquery.min.js?1406620464:3
$.ajax.success 71:13184
j jquery.min.js?1406620464:2
k.fireWith jquery.min.js?1406620464:2
x jquery.min.js?1406620464:4
b jquery.min.js?1406620464:4
Do you have any ideas how to deal with this? I appreciate your help! Many thanks!!
你有任何想法如何处理这个?我感谢您的帮助!非常感谢!!
1 个解决方案
#1
0
I found the mistake: it was an incomplete Ajax request above this code.
我发现了错误:在此代码之上是一个不完整的Ajax请求。
#1
0
I found the mistake: it was an incomplete Ajax request above this code.
我发现了错误:在此代码之上是一个不完整的Ajax请求。