前后端开发好久后,一直没怎么用前端开发了。最近任务比较急,又开始写jsp页面了。。。

       1)jquery.validate.min.js 用法总结

        https://www.cnblogs.com/xiaoqian1993/p/5822546.html  主要是自定义验证的使用

       2).    获取选中的select选项的值

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);
}
}
});

}
}

相关文章:

  • 2021-10-28
  • 2021-11-17
  • 2022-02-18
  • 2021-04-30
  • 2022-02-18
  • 2022-12-23
  • 2021-09-22
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-08
  • 2022-12-23
  • 2021-12-05
  • 2021-08-28
  • 2022-01-18
  • 2022-12-23
相关资源
相似解决方案