2012-05-12 28 views
1

私は2テキストノードと1つのjQueryオブジェクトを持って、私は私が行うときに、DOMにそれらを追加したい本:jqueryで一度にテキストとオブジェクトを追加する方法は?

$('<div>') 
.append("Ajax Failed, ") 
.append($("<span>").addClass('counter').countDown({ 
    start:o.time, 
     onEnd:function(){$.ajax(o.ajax);}, 
     onRetryEnd:function(){o.onFailed();} 
})) 
.append(" Seconds until resend request") 
.appendTo('#domElement').align({position:'absolute',parent:$('#domElement')}); 

それ意志知事(結果:Ajaxは6秒再送要求されるまで、失敗した)が、私はしたいです

var counter = $("<span>").addClass('counter').countDown({ 
    start:o.time, 
     onEnd:function(){$.ajax(o.ajax);}, 
     onRetryEnd:function(){o.onFailed();} 
}); 

$('<div>').append('Ajax Failed, ' + counter + 'Seconds until resend request'); 

結果:Ajaxが失敗しました。[オブジェクトオブジェクト]再送信要求までの秒数です。
はすぐにできますか?

答えて

3

最後の行にプラス記号があるために起こっています。次のようなものがあります。

$('<div>').append('Ajax Failed, ', counter, 'Seconds until resend request'); 

+0

+1あなたは私の考えを読んだ:) – VisioN

+0

働いて、感謝;) –

関連する問題