jQuery deferred.resolveWith() Method

Last Updated:

jQuery deferred.resolveWith() Method

The jQuery deferred.resolveWith() method resolves a Deferred object and call any doneCallbacks with the given context and array of arguments.


HTML Editor
<!DOCTYPE html> <html lang="en-US"> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> </head> <body> <h1>jQuery deferred.resolveWith() Method</h1> <button id="sss">resolveWith button</button> <script> $(document).ready(function(){ $("button").click(function(){ var deferred = $.Deferred(); deferred.then(function(value) { alert("You clicked : " +$(this).text()); alert(value); return 42; }).then(function(id){ alert('The answer : ' + id); }); deferred.resolveWith(this, ["hello world"]); }); }); </script> </body> </html>


deferred.resolveWith(context, arr);

Parameter Values

Value Type Explanation
context Required Context passed to the doneCallbacks as the this object.
arr Optional Specifies an array of arguments that are passed to the doneCallbacks.

Browser Support

Browsergoogle chromesafarifirefoxinternet Exploreredgeoperagoogle chromesafarifirefoxedgeoperaandroid webviewsamsung internet

Share this Page

Meet the Author