简体   繁体   English

如何刷新或重新加载数据

[英]How to refresh or reload data

I would like to refresh any 60 sec only the values given back from the following code inside a widget, without reload the entire page: 我想仅刷新窗口小部件内以下代码中给出的值,而不刷新60秒,而无需重新加载整个页面:

    <?php
    // display Who's Online
    if (class_exists("VisitorMaps")) {
        $visitor_maps = new VisitorMaps();
    }
    if (isset($visitor_maps)) {
       $visitor_maps->visitor_maps_manual_sidebar();
    }
    ?>

Any help will be appreciated. 任何帮助将不胜感激。

Let me know more about your problem and then i might improve my answer but you can use this js to get a response from server in json format and update only certain elements of html page /* refresh DOM for every key named 'selectors' in data dictionary */ 让我更多地了解您的问题,然后我可能会改善我的回答,但是您可以使用此js从json格式的服务器获取响应,并仅更新html页面的某些元素/ *为数据中每个名为“选择器”的键刷新DOM字典* /

/* both data and data['selectors'] need to be json objects
*/

var getJSON, refreshPage,
  __slice = [].slice;

refreshPage = function() {
  var callback, callbacks, content, data, dom, selector, selectors, _i, _len, _results;

  data = arguments[0], callbacks = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
  selectors = data['selectors'];
  for (selector in selectors) {
    content = selectors[selector];
    if (!(content === '' || content === void 0)) {
      dom = $.toDom(selector);
      setText(dom, content, true);
    }
  }
  _results = [];
  for (_i = 0, _len = callbacks.length; _i < _len; _i++) {
    callback = callbacks[_i];
    if (isFunction(callback)) {
      _results.push(callback(data));
    } else {
      _results.push(callback);
    }
  }
  return _results;
};

/* jquery getJSON function simplified
*/


/* calls the callback function with retrieved data automatically
*/


getJSON = function() {
  var args, callback, data, url;

  url = arguments[0], data = arguments[1], callback = arguments[2], args = 4 <= arguments.length ? __slice.call(arguments, 3) : [];
  return $.getJSON(url, data, function(data, status) {
    if (isFunction(callback)) {
      return callback.apply(null, [data].concat(__slice.call(args)));
    }
  });
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM