国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > JS > 正文

dojo 之基礎篇(二)之從服務器讀取數據

2024-09-06 12:42:55
字體:
來源:轉載
供稿:網友
本例子沿用 "dojo 之基礎篇" 中的內容
首先,我們在HelloWorld.html的同一級目錄,新建一個文件,名為response.txt,內容為:

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路徑. 當然按下按鈕后, 會向response.txt發送請求,此時,服務器
//將返回response.txt中的內容.這個url可以是其它的對象.比如struts中的
//***.do 或者 是一個servlet url.
function helloPressed()
{
dojo.io.bind({
url: 'response.txt',
handler: helloCallback
});
}

//處理返回數據的函數. 其三個參數是必需的.
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>
以上為所有代碼.
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 聂拉木县| 汤原县| 青田县| 石景山区| 扎鲁特旗| 永春县| 襄汾县| 隆安县| 抚松县| 汶川县| 依安县| 景泰县| 渝中区| 旬阳县| 永春县| 高邑县| 枣强县| 台北县| 昭觉县| 厦门市| 页游| 苍梧县| 赣榆县| 陵水| 邹城市| 徐水县| 获嘉县| 米泉市| 武安市| 固阳县| 大庆市| 伽师县| 五原县| 师宗县| 晋宁县| 蓬安县| 宁武县| 密山市| 衢州市| 化州市| 博乐市|