欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

dojo 之基礎(chǔ)篇(二)之從服務(wù)器讀取數(shù)據(jù)

 更新時間:2007年03月24日 00:00:00   作者:  
本例子沿用 "dojo 之基礎(chǔ)篇" 中的內(nèi)容
首先,我們在HelloWorld.html的同一級目錄,新建一個文件,名為response.txt,內(nèi)容為:

Welcome to the Dojo Hello World Tutorial

將section 2的代碼替換 為以下代碼

  <!-- SECTION 3 -->
<script type="text/javascript">
dojo.require("dojo.io.*");
dojo.require("dojo.event.*");
dojo.require("dojo.widget.*");
dojo.require("dojo.widget.Button");

//綁定url路徑. 當(dāng)然按下按鈕后, 會向response.txt發(fā)送請求,此時,服務(wù)器
//將返回response.txt中的內(nèi)容.這個url可以是其它的對象.比如struts中的
//***.do 或者 是一個servlet url.
function helloPressed()
{
dojo.io.bind({
url: 'response.txt',
handler: helloCallback
});
}

//處理返回?cái)?shù)據(jù)的函數(shù). 其三個參數(shù)是必需的.
function helloCallback(type, data, evt)
{
if (type == 'error')
alert('Error when retrieving data from the server!');
else
alert(data);
}

function init()
{
var helloButton = dojo.widget.byId('helloButton');
dojo.event.connect(helloButton, 'onClick', 'helloPressed')
}

dojo.addOnLoad(init);
</script>
以上為所有代碼.

相關(guān)文章

最新評論