problems with anchor ajax submit
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).pare开发者_JAVA百科nts('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
Try this:
$(document).ready(function() {
$('form[id=searchmore] a').click(function() {
$(this).parents('form').submit();
return false;
});
});
problem solved. the script was fine... there was another script messing up with jquery. I changed it and now it works
thx
精彩评论