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

首頁 > 編程 > JavaScript > 正文

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

2019-11-21 02:11:34
字體:
來源:轉載
供稿:網友
本例子沿用 "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>
以上為所有代碼.
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 新绛县| 邓州市| 六安市| 腾冲县| 西藏| 高密市| 正镶白旗| 从江县| 鲁山县| 镇原县| 客服| 临高县| 中宁县| 东乌珠穆沁旗| 宜君县| 昌江| 鹤庆县| 汉阴县| 巫溪县| 西乌珠穆沁旗| 千阳县| 如东县| 阆中市| 靖宇县| 普定县| 洪泽县| 衡阳市| 英超| 伊川县| 惠水县| 河南省| 绵阳市| 雷州市| 高青县| 娄底市| 灵璧县| 文登市| 岐山县| 道孚县| 洛浦县| 乌鲁木齐县|