锚定ajax提交的问题
我有一个锚点提交了带有 ajax 响应的表单。它曾经有效,但现在,由于某种原因,正在提交表单并绕过ajax调用
代码:
<script>
//makes anchor as submit
//searchmore is the id of the form
$('#searchmore a').click(function() {
$(this).parents('form').submit();
return false
});
//submit handling
$("#searchmore").submit(function() {
$.ajax({
type: "GET",
beforeSend: function(objeto){ /*before send function*/ },
url: $(this).attr('action'),
data: $(this).serialize(),
dataType: "text",
success: function(data){
$("#display_results").append(data);
}
});
return false;
});
</script>
如果我使用提交按钮提交表单,ajax响应效果很好,因此锚点一定是问题所在
,看起来语法上没有错误,有什么建议吗?
编辑:您可以检查页面此处表格位于末尾。您可以找到锚点(浅蓝色小框,上面写着“más resultados”)及其下方的提交按钮
I had an anchor that submited a form with an ajax response. It used to work, but now, for some reason, the form is being submited and bypassing the ajax call
code:
<script>
//makes anchor as submit
//searchmore is the id of the form
$('#searchmore a').click(function() {
$(this).parents('form').submit();
return false
});
//submit handling
$("#searchmore").submit(function() {
$.ajax({
type: "GET",
beforeSend: function(objeto){ /*before send function*/ },
url: $(this).attr('action'),
data: $(this).serialize(),
dataType: "text",
success: function(data){
$("#display_results").append(data);
}
});
return false;
});
</script>
if i submit the form with a submit button, the ajax response works great, therefore the anchor must be the problem
and it seems there are no errors in syntax, any suggestions?
edit: you can check the page here the form is at the end. you can find the anchor (the small light-blue box that says "más resultados") and the submit button under it
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个:
Try this:
问题解决了。脚本很好...还有另一个脚本搞乱了 jquery。我改变了它,现在它可以工作了
,谢谢
problem solved. the script was fine... there was another script messing up with jquery. I changed it and now it works
thx