I use a jQuery script for post a form.
Afert AJAX request, I don’t want to use the response.
My trouble is, the AJAX response is launch by browser.
My Script :
$(document).ready(function() {
$('button[num]').click(function(){
$.fn.validRef($(this).attr('num'));
});
$.fn.validRef = function(refId){
var R = {}
var form = $('#R'+refId+'Form')
var tab = $('#R'+refId+'Tab')
$('form input').each(function(index) {
R[$(this).attr('name')] = $(this).val();
});
$('form select').each(function(index) {
R[$(this).attr('name')] = $(this).val();
});
$.ajax({
type: "POST",
url: "/events/",
data: R,
async: false,
cache: false,
error: function() { alert('err'); },
success: function(data){
form.hide();
tab.hide();
}
});
}
});
I tried to use return false and console.log(data),
But in all case the trouble appears.
You can also give different ways to use or place the 2 previous commands.
A last thing, I use Django and the web page which request /ajax is not itself.
When I launch it from console it works ! But not when I use onclickwith my function.
I declare my function like that : function validRef(){ ... }
Resolved :
I add
return falsein click handle.