且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

jQuery Ajax调用,返回值问题

更新时间:2021-10-20 21:46:24

function FuncionCallGetMore(){
    //...    
    getMore('x-value', FuncionGetReturn);
    //...
}  

function FuncionGetReturn(error, value){
   if (!error) {
       // work value
   }
}

function getMore(from, fn){

  var initData = "&start-index=" + from;

  $.ajax({
    type:"POST",
    url: '', //removed the URL
    data: initData,
    dataType: 'json',
    success: function(result) {
      fn(false, result);
    },
    error: function(errorThrown) {
      fn(true);
    }


    });

    return;
}