How to repeat jQuery ajax call every 10 seconds?
$(document).ready(function() {
$.ajax({
type: "GET",
url: "newstitle.php",
data: "user=success",
success: function(msg) {
$(msg).appendTo("#edix");
}
});
I’ve tried to wrap the $.ajax with a function and to call the function with setInterval
$(document).ready(function() {
function ajaxd() {
$.ajax({
type: "GET",
url: "newstitle.php",
data: "user=success",
success: function(msg) {
$(msg).appendTo("#edix");
}
});
}
setInterval("ajaxd()",10000);
});
But it says “ajaxd is not defined”
Your method should not be placed inside the ready method, or it would only be available there and not outside.