0
I have the following code that executes a query in DB with ajax. So when in Success I put append instead of replaceWith, the function works perfectly and runs every 5 seconds, but when I enter replaceWith in place of the append, the function only runs once and does not execute setimeout.
PS: php variables appear like this because the function is inside a php query.
function fetchdata". $row2['id'] ."(){
var dz='". $row2['id'] ."';
var dld='$jmmj';
$.ajax({
type: 'POST',
data: {dz: dz},
url: 'submit4.php',
success: function(datas){
if(datas!==''){
$('#message18w". $row2['id'] ."').replaceWith(datas);
}else{ $('#message18w". $row2['id'] ."').replaceWith('');}
setTimeout(fetchdata". $row2['id'] .",5000);
},
error:function(datas){
setTimeout(fetchdata". $row2['id'] .",5000);
},
complete:function(datas){
setTimeout(fetchdata". $row2['id'] .",5000);
}
});
}
$(document).ready(function(){
setTimeout(fetchdata". $row2['id'] .",5000);
});
even so the problem persists, this setTimeout was introduced by me in the search for a solution
– Music Lyrics HQ
I already solved the problem, I was not even in that code piece but in what I put as replace
– Music Lyrics HQ
That’s what I was about to say. Good q solved! Good luck!
– Sam