jQuery Ajax从PHP获取变量并设置值到其他jquery函数

i'm trying to get a value from a get ajax request and put it into another jquery function

  $(document).ready(function(){
    var callAjax = function(){
      $.ajax({
        method:'get',
        url:'getrecord.php',
        success:function(data){
          $("#sample").html(data);
        }
      });
    }
    setInterval(callAjax,10000);
  });

in getrecord.php i just have an echo rand number which i need to place in this other function -where number 10 is placed- instead of be printed in sample div

$('#ten').prop('number', 10).animateNumber({
        number: 100
    },
    2000
);

how can i do it? thanks in advance!

Put the other code in the success callback.

  $(document).ready(function(){
    var callAjax = function(){
      $.ajax({
        method:'get',
        url:'getrecord.php',
        success:function(data){
          $("#ten").prop('number', data).animateNumber({
            number: 100
          }, 2000);
        }
      });
    }
    setInterval(callAjax,10000);
  });