<!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>