I want to use the onreadystatechange
event from the (underlying) XMLHttpRequest
of JQuery's (2.0.2) $.ajax(...)
to fire synchronous ajax requests so I can show an accurate status indication to the end user for long running requests. But it seems this functionality has been removed from the latest version of JQuery (see here), making spinners with asynchronous web requests the only option for representing the activity to the user.
using XMLHttpRequest
I would do something like the following (though I still wan't to use JQuery), is there still a way in JQuery to gain access to a readystate change function? Is there perhaps a plugin that exposes the onreadystatechange
event?
function pad(width, string, padding) { // from stackoverflow.com/a/15660515/424963
return (width <= string.length) ? string : pad(width, string + padding, padding)
}
$(function(){
$("<div>Loading</div>").appendTo($("body"));
var anticache = "?anticache=" + new Date().getTime();
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4){
$("div").html("Done");
}
else {
$("div").html("Loading" + pad(xhr.readyState, "", "."));
}
};
xhr.open("POST", "jsfiddle.net" + anticache, true );
xhr.send();
});
Following issue: Let's say, we have an object like this: $scope.Something = { 'a' : { object... }, 'b' : { another object... } } This Something-object is also rendered in the view as follows: <...
Following issue: Let's say, we have an object like this: $scope.Something = { 'a' : { object... }, 'b' : { another object... } } This Something-object is also rendered in the view as follows: <...
I need to capitalize the first letter of various html elements such as p, h2, h3, h4. This stack question has helped me, however, it only targets the p tag. How can I say to target more than one tag? ...
I need to capitalize the first letter of various html elements such as p, h2, h3, h4. This stack question has helped me, however, it only targets the p tag. How can I say to target more than one tag? ...
HTML: <select id="mySelect"> <option>Apple</option> <option>Orange</option> <option>Pineapple</option> <option>Banana</option> &...
HTML: <select id="mySelect"> <option>Apple</option> <option>Orange</option> <option>Pineapple</option> <option>Banana</option> &...
So let's say we have the following XML structure: <property> <label>Label 1</label> <value>value 1</label> </property> <property> <label>...
So let's say we have the following XML structure: <property> <label>Label 1</label> <value>value 1</label> </property> <property> <label>...