我在更新jquery进度条时遇到了一些问题.在页面加载期间,此进度条不在文档中,我只是在用户单击按钮时添加它,ding类似于:
$(this).parent().append('<div class="progressbar"></div>');
$(this).parent().children('div.progressbar').show();
$(this).parent().children('div.progressbar').progressbar({value: 20});
Run Code Online (Sandbox Code Playgroud)
然后,使用超时,我正在尝试更新它
function updateProgressBar() {
$('.progressbar').each(function() {
myNewValue = getNewValue();
$(this).progressbar('value', 50);
});
setTimeout('updateProgressBar()', 5000);
}
setTimeout('updateProgressBar()', 5000);
Run Code Online (Sandbox Code Playgroud)
调试控制台抱怨说:"未捕获:无法在初始化之前调用进度条上的方法:尝试调用方法'值'"在这里搜索我发现问题可能与加载页面后进度条的初始化有关
有人能帮助我吗?
提前致谢
- 编辑 -
谢谢布莱恩,我正在尝试你的解决方案,但我不适合我
现在我有了这段代码
function startProgress() {
$(this).parent().append('<div class="progressbar"></div>');
$(this).siblings('.progressbar').show();
$(this).siblings('.progressbar').progressbar({value: 0});
function updateProgress() {
$('.progressbar').each(function() {
myNewValue = getNewValue($(this).parent().parent().attr('id'));
$(this).progressbar('value', myNewValue);
});
setTimeout('updateProgress', 5000);
}
setTimeout('updateProgress', 5000);
}
Run Code Online (Sandbox Code Playgroud)
控制台说没有updateProgress定义
- 编辑 -
非常感谢!!!
现在我有一个非常确定的版本可行...
这是我目前的代码
if($(this).siblings('.progressbar').size() == 0) {
$(this).parent().append('<div class="progressbar"/>');
$(this).siblings('.progressbar').progressbar({value: 0});
}
$(this).siblings('.progressbar').show();
function updateProgress() {
$('.progressbar').each(function() { …Run Code Online (Sandbox Code Playgroud) 我正在尝试学习如何使用libnetfilter_queue。我已经编译了库提供的示例。
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <netinet/in.h>
#include <linux/types.h>
#include <linux/netfilter.h> /* for NF_ACCEPT */
#include <libnetfilter_queue/libnetfilter_queue.h>
/* returns packet id */
static u_int32_t print_pkt (struct nfq_data *tb)
{
int id = 0;
struct nfqnl_msg_packet_hdr *ph;
struct nfqnl_msg_packet_hw *hwph;
u_int32_t mark,ifi;
int ret;
char *data;
ph = nfq_get_msg_packet_hdr(tb);
if (ph) {
id = ntohl(ph->packet_id);
printf("hw_protocol=0x%04x hook=%u id=%u ",
ntohs(ph->hw_protocol), ph->hook, id);
}
hwph = nfq_get_packet_hw(tb);
if (hwph) {
int i, hlen = ntohs(hwph->hw_addrlen);
printf("hw_src_addr=");
for (i = 0; …Run Code Online (Sandbox Code Playgroud)