jQuery deferred.progress() Method
This deferred.progress() method in jQuery is used to add handlers which are to be called when the Deferred object generates progress notifications.
Syntax:
deferred.progress(progressCallbacks[, progressCallbacks])
Parameters:
- progressCallbacks: This parameters is a function, or array of functions, which are to be called when the Deferred generates progress notifications.
- progressCallbacks: It is an optional parameters and is a function, or array of functions, which are to be called when the Deferred generates progress notifications.
Return Value: This method returns the deferred object.
Example 1: In this example, The progress() method is called with the reject() method.
html
<!DOCTYPE HTML>
< html >
< head >
< script src =
</ script >
</ head >
< body style = "text-align:center;" >
< h1 style = "color:green;" >
GeeksForGeeks
</ h1 >
< p >
JQuery | deferred.progress() method
</ p >
< button onclick = "Geeks();" >
click here
</ button >
< p id = "GFG" ></ p >
< script >
function Func(val, div) {
$(div).append(val);
}
function Geeks() {
var def = $.Deferred();
def.fail(Func);
def.progress(Func);
def.reject('"Func" is added as '
+ 'progressCallbacks using '
+ 'progress() method when '
+ 'Deferred object is rejected',
'#GFG')
}
</ script >
</ body >
</ html >
|
Output:
Example 2: In this example, the progress() method is called with the resolve() method.
html
<!DOCTYPE HTML>
< html >
< head >
< script src =
</ script >
</ head >
< body style = "text-align:center;" >
< h1 style = "color:green;" >
GeeksForGeeks
</ h1 >
< p >
JQuery | deferred.progress() method
</ p >
< button onclick = "Geeks();" >
click here
</ button >
< p id = "GFG" ></ p >
< script >
function Func(val, div) {
$(div).append(val);
}
function Geeks() {
var def = $.Deferred();
def.done(Func);
def.progress(Func);
def.resolve('"Func" is added as '
+ 'progressCallbacks using '
+ 'progress() method when '
+ 'Deferred object is resolved',
'#GFG')
}
</ script >
</ body >
</ html >
|
Output:
Last Updated :
14 Jul, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...