我想知道是否有一种方法可以让 jquery 一次加载一行。我用的是
var old = $('#screen').html(),
str = $.URLEncode(glength);
$('#screen').load('returns.php?c='+str+'',{},function(response, status, xhr){
if (status == "error") {
var msg = "FATAL ERROR: ";
$("#screen").html("\n"+ xhr.status);
$(this).prepend(old);
} else {
$(this).prepend(old);
$('#command').focus();
}
});
加载数据。 #screen 是一个 pre。它得到这样的变量:
******************************************************************************
login [username] [email] | Log in to the system
logout | Log out of the system
data | Display logged in user information
******************************************************************************
这可能吗,还是我在做梦?
最佳答案
response
是否包含多行数据?
您可以使用setTimeout
var lines = response.split("\n");
var time = 0;
$(lines).each(function(i) {
setTimeout(function(){
$("<span />").html(this).prependTo("place");
}, time);
time += 200;
});
所有行都将被附加,每行之间有大约 200ms
延迟。
关于jquery - 一次加载一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5845356/