After struggling for 3 hours trying to fix an issue, I turned to the internet for help. Can someone please assist me with the following challenge:
How can I create a loop of AJAX requests that continues to run until the data received from the AJAX call is equal to "stop" while using while and setting async to true?
Here is an unsuccessful example of what I have tried:
do {
promise = json('json.php');
promise.success(function again(data) {
if(data === 'stop') {
return false;
} else {
console.log('data');
}
});
} while (again());
function json(url) {
return $.ajax({
type: "GET",
dataType: 'text',
url: url
});
}