prototype中的ajax非同步載入

來源:互聯網
上載者:User

標籤:

jquery前台處理:var param = {a:a};$.post("*.do",param,function(data) {    var columHtml =  "";    $.each(data, function(i, item) {columHtml = columHtml + "<option value=‘"+item[0]+"‘>"+item[1]+"</option>"    });            $("#columnid").append(columHtml);  });後台:返回json 格式=========================================================================================================================prototype.js使用ajax級聯:後台返回json格式的list,前台使用ajax 處理json 和 list 
前台頁面:<select name="id" id="id" onchange="aa(this.value)"><option value="0">請選擇</option></select>
js方法function aa(id){function onSuccess(response) {var data = response.responseText.evalJSON(); var colList = data.dataList;var columHtml = "";for(var i = 0;i<colList.length;i++){columHtml = columHtml + "<option value=‘"+colList[i].id+"‘>"+colList[i].colName+"</option>"} alert(columHtml);var a = $(‘columnid‘);alert(a.innerHTML); $(‘columnid‘).innerHTML = columHtml; }function onFailure(response) { alert(‘資料請求異常‘); }var params = "&websiteId="+websiteid;ajax = new Ajax.Request(‘a.do‘,{method: ‘POST‘,asynchronous: true,parameters:params,onSuccess : onSuccess,onFailure : onFailure }); }
後台action處理:JSONObject jsonObject = new JSONObject();jsonObject.put("dataList", maplist); this.getPrintWriter(jsonObject);
xml處理:<action name="a" class="AAction" method="a"><result name="success" type="json"></result></action>

  

prototype中的ajax非同步載入

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.