Now I can make the alert box show, depending on each time I press submit, the alert box keeps increasing. I want it to show only once.
js
$('.form-ajax').on('submit',function(e){
e.preventDefault();
var form = $(this);
var url = form.attr('action');
var method = form.attr('method');
var data = form.serialize();
var callback = form.attr('callback');
if(typeof callback !=='string'){
callback = function(response){
$("#error-box").append('<div class="alert alert-success alert-block">'+'<button
type="button" class="close" data-hide-closest=".alert" data-
dismiss="alert">×</button>'+'<strong>'+response.message+'</strong>'+'</div>');
if(typeof response.url ==='string' && response.url!=''){
window.location.href=response.url;
}else{
}
}
}
Helper.ajax (url,method,data,callback)
});
Views:
<div id="error-box">
</div>
You can do like this
Let popup = $(<div id="error-box"></div>);
//Append popup were you like and when you are done just remove this from dome elements.
$(selector).append(popup);
//When u r done
popup.remove();
You can use a modal.
<div class="modal hide" id="myModal" >
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3>Error</h3>
</div>
<div class="modal-body">
Your error message here.
</div>
<div class="modal-footer">
</div>
</div>
When you need to show it.
$('#myModal').modal('show');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.