zoukankan      html  css  js  c++  java
  • AJAX的同步返回结果值

    function makeJQGridDataFromList(url) {     var rowData;     var viewPage = 0;     var viewTotal = 0;     var viewRecords = 0;
        var resultObject;
        $.ajax({            type:"GET",         url:url,            async: false,         success:function(args){             if(args.result==true)             {                 try                 {                     viewPage = args.cond.pageIndex;                     viewTotal = args.cond.recordCountPerPage;                     viewRecords = args.cond.totalCnt;
                        rowData = jsonMakeRowsForGrid(args.data);                 }                 catch (e)                 {                     console.debug("Error!");                     alert("Invalid data");                     return;                 }             } else             {                 alert("API return ERROR!");                 return;             }         },         error:function(e){             alert("Fail AJAX communication");             return;         }     });
        resultObject = {         page : viewPage,         total : viewTotal,         records : viewRecords,         rows : rowData     };
        return(resultObject); }

    You can test the following method.

    (In the other file (html or js))

    var gridData = makeJQGridDataFromList(openAPIUrl);
    console.debug(">> " + JSON.stringify(gridData));
    

    You can see the gridData.

  • 相关阅读:
    json数组解析
    sparkschedule任务类
    elasticsearch的操作类
    删除hbase的region步骤和代码
    zookeeper持有者类
    zookeeper主节点竞争类
    剑指offer(61-66)编程题
    Codeforces Round #190 (Div. 2) B. Ciel and Flowers
    一些傍晚的感想
    Codeforces Round #307 (Div. 2) D. GukiZ and Binary Operations
  • 原文地址:https://www.cnblogs.com/hannover/p/4227686.html
Copyright © 2011-2022 走看看