I'm trying to get some live output from an AJAX request.
This is the code I'm using:
$.ajax({ type: "GET",
url: "test.php?delete=students",
async: true,
success : function(data) {
console.log(data)
}
});
When triggered by a link on my web page a spinning animation is shown to show that something is happening. I'd also like to show in a div
the output from test.php as it is running.
test.php has a simple loop which loops through all students and deletes them, it then echo "$student removed";
When run from the command line the removals are shown, when run via AJAX I only get the animation not the output.
I'm not sure how to get that, I've tried a couple of plugin's with out much success. I've also tried to use XMLHttpRequest
and responseText
but i'm not sure how to use this correctly.
Ideally I'd like each removal to be shown in a #status
div.
Can any one advise how to do this ?
UPDATE
progress : function(data) {
console.log(data);
},
I've added the above and move I get some output in the console.
ProgressEvent {isTrusted: true, lengthComputable: false, loaded: 44, total: 0, type: "progress"…}
Expanding that I can see the responsetext which contains the data I'm after.
How do I get that so I can append it to a div
?