先后端开发很久后,一直没怎么用前端开发了。最近任务比较急,又开始写jsp页面了。。。html
1)jquery.validate.min.js 用法总结前端
http://www.javashuo.com/article/p-fzibwwfa-e.html 主要是自定义验证的使用jquery
2). 获取选中的select选项的值ajax
var chooseOption = $("#durationStrategy").find("option:selected").val();
$("#showStrategy").show(); //显示
$("#twoPrice").hide(); //隐藏
$("#passengerDiv").empty() //div空初始化
hiddenPassJson != undefined //不为空判断 防止修改时候出现undefine异常
var json = eval("(" + hiddenPassJson + ")"); //解析json
for(var i =0;i<json.length;i++){
var type = json[i];
console.log(type.属性); //显示json 属性
for(var k in type){
console.log(type.属性)
}
}
3)ajax请求
/**根据城市获取区域*/function getRuleList(){ var cityId = $("#city").find("option:selected").val(); console.log("cityId:" + cityId); if(!cityId){ alert("请选择城市"); }else{ var url ="${ctx}intercity/strategy/getLineByCityId.html?cityId="+cityId; $.ajax({ type:"GET", url:url, error: function (XMLHttpRequest, textStatus, errorThrown) { alert("获取失败"); }, success: function (data) { data = $.parseJSON( data ); if (data.code==0){ $('#ruleId').empty(); $('#ruleId').append('<option value="" selected="selected">所有</option>'); $.each(data.ruleList,function(i,o){ $('#ruleId').append('<option name="ruleId" value="'+o.lineId+'">'+o.lineName+'</option>'); }); }else { alert("抱歉,操做失败!!! \r\n "+data.msg); } } }); }}