User FAQs
If you have a question, please send it to us.
1) Can you give some examples of JQuery AJAX functions ?
$.get() - load data from the server using a HTTP GET request
$.post() - load data from the server using a HTTP POST request
$.ajax() - perform an asynchronous HTTP (Ajax) request
All these functions and methods use XMLHttpRequest under the hood.
2) Write code to create a promise object using JQuery ?
You can create a promise object by using the $.Deferred method.
There are a number of methods available on this Deferred object
resolve -
resolvewith - passes data to the promises object subscribers
notify -
notifywith - passes data to the promises object subscribers
reject -
rejectwith - passes data to the promises object subscribers
promise -
There are a number of methods available on the Promise object
done -
fail -
always -
pipe -
progress -
state -
then -
function timeoutAsync(milliseconds) {
var deferred = $.Deferred();
setTimeout(function () { deferred.resolve(); }, milliseconds); // run this code when the time has expired
return deferred.promise(); // changes the state of the promise object to resolved
};
function abcAsync() {
var promise = timeoutAsync(2000);
promise.done(function () { alert('done!') });
return promise; // you should always return a promise
};
© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited TopPrevNext