Good morning friends, I have this code:
$(document).ready(function(){
$('button').on('click',function(e){
e.preventDefault();
var codigo = $(this).attr('id');
$.ajax({
type: 'post',
url: '<?= base_url('posts/apaga'); ?>',
data: 'codigo='+codigo,
success: function(msg){
if(msg.indexOf("Erro") > -1){
$('#ret_apaga_post').html(msg);
}else{
$('#reload_post').html(msg);
}
}
});
});
});
The situation is that I have a list of data returned from the database, and I have a delete button for each record.
What happens, is that depending on the return PHP
, I need to load on different divs. I found tips on msg.indexOf("Erro")
, on jquery contains selector
and also str.match(/Erro/)
, but only work the first time.
I also tried to add ajax cache: false
, also to no avail.
Thank you in advance.