i want send ajax call with loop parameter named [id] in url starts request.php?id=1 ends id=9
and send every call after 3 second .
I’m a beginner in the JavaScript, I don’t know where to start the idea, this is my code:
$.ajax({
type: 'POST',
url: 'request.php?id=1',
data: {apiId:actionBtn},
dataType: 'json',
cache: false,
beforeSend: function(){
$('.submitBtn').attr("disabled","disabled");
$('#addApi').css("opacity",".5");
},
success: function(response){
}
});
2
Answers
First, make the
id
into a variablelet id = 1;
. Then you can use the JavaScriptsetInterval
(https://developer.mozilla.org/en-US/docs/Web/API/setInterval) function to make a function-call every x seconds.