我想刷新窗口小部件中以下代码返回的值,只需刷新60秒,而无需重新加载整个页面:
<?php
// display Who's Online
if (class_exists("VisitorMaps")) {
$visitor_maps = new VisitorMaps();
}
if (isset($visitor_maps)) {
$visitor_maps->visitor_maps_manual_sidebar();
}
?>
任何帮助将不胜感激。
答案 0 :(得分:0)
让我更多地了解您的问题,然后我可以改进我的答案 但您可以使用此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)));
}
});
};