タイトル募集中3.0

しがないITソルジャーの雑記。

【MooTools】1.2.2を少しだけ

FancyUploadを触ってる都合上,MooToolsのソースも読んでるんだけど,

  • MooTools1.2.2アップデートまとめ(ttp://takahashifumiki.com/web/programing/628/)

によると,1.2.2でMoreのほうが更新されて,

Requestクラスの拡張。JSONPが新たに加わったこと、リクエストをキューに入れ(順番待ちさせ)たり、定期的に実行させるクラスが追加。

とのことだったので,ちょっと試してみました.

  • MooTools Docs - Request/Request.Periodical(ttp://mootools.net/docs/more/Request/Request.Periodical)

html側

<ul id="status"></ul>

javascript

new Request({
	url:"http://localhost/hoge.php",
	method: 'get',
	onSuccess: function(responseText) {
		new Element('li', {text: responseText}).inject($('status'), 'bottom');
},
onFailure: function() {
		new Element('li', {text: 'error!'}).inject($('status'), 'bottom');
	}
}).startTimer({
    param: 'hogeeeeee'
});

↑のはデフォルトの設定間隔でリクエストを送るけど,リクエストを送る間隔などは,オプションで設定できる.

new Request({
	url:"http://localhost/hoge.php",
	method: 'get',
	initialDelay: 1000,
	delay: 5000,
	limit: 15000
}).startTimer({
	param: 'hogeeeeee'
});