This deferred.resolve() method in JQuery is used to resolve a Deferred object and call any doneCallbacks with the given arguments.
Syntax:
deferred.resolve([args])
Parameters:
- args: This is optional parameters and is arguments which are passed to the doneCallbacks.
Return Value: This method returns the deferred object.
There are two examples discussed below:
-
Example: In this example, The resolve() is called with the arguments.
<!DOCTYPE HTML>
< html >
< head >
< title >
JQuery | deferred.resolve() method
</ title >
</ script >
</ head >
< body style = "text-align:center;" >
< h1 style = "color:green;" >
GeeksForGeeks
</ h1 >
< p id = "GFG_UP" >
</ p >
< button onclick = "Geeks();" >
click here
</ button >
< p id = "GFG_DOWN" >
</ p >
< script >
var el_up = document.getElementById("GFG_UP");
el_up.innerHTML = "JQuery | deferred.resolve() method";
function Func(val, div){
$(div).append(val);
}
function Geeks() {
var def = $.Deferred();
def.done(Func);
def.resolve(
'resolve() method is called with arguments
and Deferred object is resolved', '#GFG_DOWN')
}
</ script >
</ body >
</ html >
|
-
Output:
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
14 Jul, 2020
Like Article
Save Article