`
Lstoryc
  • 浏览: 76093 次
文章分类
社区版块
存档分类
最新评论

Jquery实现ajax动态生成select标签并设置选中

 
阅读更多
a : function () {
			$.ajax({
				url : 'xxxxxxxx.action',
				method : 'post',
				success : function (data) {
					if (data.success == "true") {
						var profiles = data.profiles;
						for (var i=0;i<profiles.length;i++) {
							if (profiles[i].profileType == "sms") {
								//TODO
								$('#otpForm input[name="smsPhoneNumber"]').attr('value', profiles[i].identity);
								jQuery("<option>SMS</option>").attr("value",profiles[i].profileType).appendTo("#otpForm #prePushOTPMethod");
							}
							if (profiles[i].profileType == "was") {
								$('#otpForm input[name="whatsappPhoneNumber"]').attr('value', profiles[i].identity);
								jQuery("<option>Whatsapp</option>").attr("value",profiles[i].profileType).appendTo("#otpForm #prePushOTPMethod");
							}
						}
					} else {}
				}
			});

$.ajax({
                url : 'aaaa.action',
                method : 'post',
                success : function (data) {
                    if (data.success == "true") {
                        var preferPushOTPType = data.preferredType;
                         $("#otpForm #prePushOTPMethod").val(preferPushOTPType);
                        //$("#otpForm #prePushOTPMethod").find("option[value=" + preferPushOTPType + "]").attr("selected",true);
                    } else {}
                }
            });

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics