欧美国产另类久热|951超碰伊人久久|伊人影视久久久久|色婷婷亚洲小电影|色东京热69XX|婷婷玖玖深爱网|加勒比东京热网站|无码A级毛片在线观看|一级a毛一级a看|中文字幕人妻欧美

jQuery ajax請(qǐng)求返回list數(shù)據(jù)動(dòng)態(tài)生成input標(biāo)簽,并把list數(shù)據(jù)賦值到input標(biāo)簽
來(lái)源:易賢網(wǎng) 閱讀:2076 次 日期:2016-07-15 15:31:07
溫馨提示:易賢網(wǎng)小編為您整理了“jQuery ajax請(qǐng)求返回list數(shù)據(jù)動(dòng)態(tài)生成input標(biāo)簽,并把list數(shù)據(jù)賦值到input標(biāo)簽”,方便廣大網(wǎng)友查閱!

這篇文章主要介紹了jQuery ajax請(qǐng)求返回list數(shù)據(jù)動(dòng)態(tài)生成input標(biāo)簽,并把list數(shù)據(jù)賦值到input標(biāo)簽的相關(guān)資料,需要的朋友可以參考下

直接給大家貼代碼了,具體內(nèi)容如下所示:

// js

<script type="text/javascript">

function myBtn_f() {

var cnt = $('#myCnt').val();

syncAjax('myAjax.html', {

'cnt' : cnt

}, function(result) {

if (100 == result.statusCode) {

var data = result.lst;

var $d = $('#myDiv');

alert("[" + data + "]");

for ( var i = 0; i < data.length; i++) {

var input1 = $("<input type='text' name='input1' />");

input1.attr('value', data[i]);

$d.append(input1);

}

} else {

alert("error");

}

});

}

function syncAjax(myUrl, myData, sufn) {

$.ajax({

url : myUrl,

data : myData,

type : 'post',

dataType : 'json',

cache : false,

async : false,

success : function(result) {

if (result.statusCode == 200) {

alert("會(huì)話超時(shí),請(qǐng)重新登錄!");

window.location.href = "index.jsp";

} else {

if (sufn)

sufn(result);

}

},

error : function(msg) {

alert("error:" + msg);

}

});

};

</script>

//html

<tr>

<td><input type="text" id="myCnt" /></td>

<td><div id="myDiv"></div></td>

</tr>

<input id="myBtn" type="button" value="create" onclick="myBtn_f()" />

// 后臺(tái)

@RequestMapping("myAjax")

@ResponseBody

public String myAjax(

@RequestParam(defaultValue = "0", required = false) int cnt) {

List<String> lst = new ArrayList<String>();

for (int i = 0; i < cnt; i++) {

lst.add("no:" + i);

}

JSONObject result = new JSONObject();

result.put("statusCode", 100);

result.put("lst", lst);

return result.toString();

}

關(guān)于jQuery ajax請(qǐng)求返回list數(shù)據(jù)動(dòng)態(tài)生成input標(biāo)簽,并把list數(shù)據(jù)賦值到input標(biāo)簽的全部介紹到此結(jié)束,希望對(duì)大家有所幫助!

更多信息請(qǐng)查看網(wǎng)絡(luò)編程
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請(qǐng)考生以權(quán)威部門(mén)公布的正式信息和咨詢?yōu)闇?zhǔn)!
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡(jiǎn)要咨詢 | 簡(jiǎn)要咨詢須知 | 新媒體/短視頻平臺(tái) | 手機(jī)站點(diǎn)

版權(quán)所有:易賢網(wǎng)