I had a form that when I clicked on submit it was submitted. Then that form hid and the result of action page showed in div with classname=dig
.
It was worki
Try with form
submit and $(that).closest('.dig').empty()
to find the .dig
.In this snippet is not working .Snippet blocked some ajax function call
change the button as type="submit"
Note create the ajax function is separate and call with new ajax
like constructor .Its not disturbing on going ajax
$(document).ready(function(){
$("form").on('submit',function(e) {
var url = 'http://seller.ir/test';
new ajax($(this))
e.preventDefault();
});
})
function ajax(that){
$.ajax({
type: "POST",
url: url,
data: $(that).serialize(),
success: function(data) {
$(that).closest('.dig').empty()
},
error:function(jqXHR, textStatus, errorThrown){
console.log(textStatus)
}
});
}
.dig {
width: 200px;
height: 30px;
border: 1px solid #000
}