Search code examples
jqueryajaxanimationcreatejs

Tweenjs and $.ajax giveme an error in animations


I 'm using CreateJS to achieve animations but the problem happens when I make an AJAX call while the animation is running, after completing the ajax call, the animation is running ends but the new animations do not work and it's like the CreateJS object had disabled , any ideas or someone who has been the same to me? The code is rather long but basically contains:

 function Core(){
  _private.stage.update();
  _helper.hideLoading();
  createjs.Ticker.setFPS(100);
  createjs.Ticker.on("tick",onTickEvent);
 }

 function onTickEvent(event) {
  _private.stage.update(event);

createjs.Tween.get(_private.obj)
.wait(_waitTime)
.to({ alpha: 0, x: _global.objInitX, y: _global.objInitY },50,createjs.Ease.getPowInOut(1))
.to({ alpha: 1, x: _global.objFinX, y: _global.objFinY },5500, createjs.Ease.getPowInOut(2))
.call( onCompleteEvent );

}

My first call if it works and this on page load but then I'll use a SetInterval Javascript to use the $ .ajax

SetInterval(function(){
 $.ajax({

 });
},30000);

Im getting crazy for this, sorry for my bad english. Grettings.


Solution

  • Thanks God this was resolved, I used it:

    var xhr = new XMLHttpRequest();
    xhr.open('POST', _sys.Host + path, true);
    xhr.setRequestHeader('Content-Type', 'application/json');
    xhr.onreadystatechange = function()
    {
      if (xhr.readyState == 4 && xhr.status == 200)
      {
         onsucc(xhr.responseText); 
      }
    };
    xhr.send(data);
    

    I dont know why canvas or Tweenjs malfunctions when calling $ .ajax.
    All is ok now.
    Thanks for help.
    Regards.