最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

jQuery ajax請(qǐng)求返回list數(shù)據(jù)動(dòng)態(tài)生成input標(biāo)簽,并把list數(shù)據(jù)賦值到input標(biāo)簽

 更新時(shí)間:2016年03月29日 12:00:51   投稿:mrr  
這篇文章主要介紹了jQuery ajax請(qǐng)求返回list數(shù)據(jù)動(dòng)態(tài)生成input標(biāo)簽,并把list數(shù)據(jù)賦值到input標(biāo)簽的相關(guān)資料,需要的朋友可以參考下

廢話不多說(shuō)了,直接給大家貼代碼了,具體內(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ì)大家有所幫助!

相關(guān)文章

最新評(píng)論

贵德县| 绥滨县| 平山县| 临沂市| 当阳市| 石门县| 衡山县| 金乡县| 万年县| 开封县| 浏阳市| 泰来县| 岳普湖县| 边坝县| 金塔县| 霍林郭勒市| 乐平市| 闽侯县| 伽师县| 夹江县| 南郑县| 尤溪县| 霍林郭勒市| 葫芦岛市| 紫阳县| 星子县| 吴堡县| 长垣县| 玛纳斯县| 隆安县| 玉门市| 永春县| 大足县| 明水县| 凭祥市| 榆树市| 汉源县| 浮山县| 天等县| 志丹县| 吕梁市|