How to get SharePoint and jQuery.Deferred demo working

Hi all,

I am trying to get a jQuery.Deferred demo to work without any luck. The code is shown below:

***********Script .js****************

function redirectToDownloadsPage() {
var clientContext;
var website;

SP.SOD.executeFunc('sp.js', 'SP.ClientContext', sharePointReady);

 function sharePointReady() {
     clientContext = SP.ClientContext.get_current();
     website = clientContext.get_web();
 
     clientContext.load(website);
     clientContext.executeQueryAsync(onRequestSucceeded, onRequestFailed);
 }
 
 function onRequestSucceeded() {
     var deferred = jQuery.Deferred();
    
     jQuery(".box").animate({left:"200px"},5000, function(){
        deferred.resolve();
     });   
      return deferred.promise();
 }
 
 function onRequestFailed(sender, args) {
     alert('Error: ' + args.get_message());
 }
 
     function executeAfterAnimation() {
      alert(website.get_url());
 }

    onRequestSucceeded().done(function(){
       executeAfterAnimation();
    });
};

redirectToDownloadsPage()

***************Style.css*******************
.box{
   width: 100px;
   height: 100px;
   background-color: red;
   ;
}
*******************************************

<body>
    <div class="box"> 
    </div>  
</body>
</html>

*******************************************
I hope you can help

CEBlueSky

September 11th, 2015 8:54pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics