tengo una llamada ajax
comojQuery: carreras ajax ambos manipuladores - hecho y dejar
$.ajax({
type: 'POST',
url: 'addVideo',
data: {
video_title: title,
playlist_name: playlist,
url: id
// csrfmiddlewaretoken: '{{ csrf_token }}',
},
done: bootstrap_alert.success('video saved successfully'),
fail: bootstrap_alert.error('There were some errors while saving the video. Please try in a while')
});
y acciones como
// setting up alerts on action
bootstrap_alert = function() {}
bootstrap_alert.success = function(message) {
$('#feature').prepend('<div class="alert alert-success"><a class="close" data-dismiss="alert">×</a><span>'+message+'</span></div>');
}
bootstrap_alert.error = function(message) {
$('#feature').prepend('<div class="alert alert-error"><a class="close" data-dismiss="alert">×</a><span>'+message+'</span></div>');
}
Cuando el extremo delantero hace llamada AJAX, veo tanto las notificaciones en al mismo tiempo
video saved successfully
There were some errors while saving the video. Please try in a while
¿Es que no estoy haciendo la llamada ajax correctamente?
ACTUALIZACIÓN
cambiar done
a success
resultados en mismo comportamiento
// send the data to the server using .ajax() or .post()
$.ajax({
type: 'POST',
url: 'addVideo',
data: {
video_title: title,
playlist_name: playlist,
url: id
// csrfmiddlewaretoken: '{{ csrf_token }}',
},
success: bootstrap_alert.success('video saved successfully'),
fail: bootstrap_alert.error('There were some errors while saving the video. Please try in a while')
});
La respuesta del servidor es HTTP/1.0" 200 3200
, creo que el fail
no deben recibir la llamada
¿Estás seguro de que '$ ('# feature')' no está modificado por otra parte de tu código? –
Sí, no está modificado – fullstackcrash