Inside a typical ajax response you would simply just print out the data to a div. I want to take the data response and split it up into an array, then iterate that array and add a random delay between appends.
In this specific example I am splitting up the response into each
tag. Then I am looking to add a delay before printing these responses.
So far this has not worked for me. It will only showcase the data response in full, even if I iterate through the array with setTimeout.
//start the ajax
$.ajax({
//this is the php file that processes the data and send mail
url: "/a_example.php?sim",
target: '#crap', // target element(s) to be updated with server response
//GET method is used
type: "POST",
//pass the data
data: data,
//Do not cache the page
cache: false,
success: function(data) {
var patt = /<p>(.*?)<\/p>/g;
var result = data.match(patt);
var i;
//alert(result.length);
for (i = 0; i < result.length; i++) {
showResultMock(result[i]);
}
},
complete: function() {
}
});
function showResultMock(result){
setTimeout(function(){ $('#modaldraftdetails .modal-body .draft-results').append(result); }, 2000);
}