ajax 文本框改变事件 局部刷新 报错

qq_39881510 2017-11-15 08:36:45

@RequestMapping(value="selNursinglevelall", method=RequestMethod.GET)
@ResponseBody
public List<Nursinglevel> selNursinglevelall(String nursinglevel_object){
List<Nursinglevel> nursinglevel1 = nursinglevelservice.selNursinglevelAll(nursinglevel_object);
return nursinglevel1;
}

@RequestMapping(value="selNursinglevel", method=RequestMethod.GET)
public String selNursinglevel(Model model,Nursinglevel nursinglevel ,String nursinglevel_object){
List<Nursinglevel> nursinglevel2 = nursinglevelservice.selNursinglevel(nursinglevel);
model.addAttribute("nursinglevel2", nursinglevel2);
return "/WEB-INF/Check/NewFile1";
}
$("#nursinglevel_object").change(function (){
var targetUrl = $(this).attr("data-getDataUrl");
//获得一级select的值
var firstValue = $(this).val();
//如果一级select的值为null,隐藏二、,并返回
$.ajax({
type:'get',
url:targetUrl,
data:{
nursinglevel_object:firstValue
},
cache:false,
dataType:'json',
success:function(nursinglevel1){
var input = "<input value='"+nursinglevel1.nursinglevel_description+"'></input>" ;
var input2 = "<input value='"+nursinglevel1.nursinglevel_expenses+"'></input>";
var input3 = "<input value='"+nursinglevel1.cost+"'></input>";
var input4 = "<input value='"+nursinglevel1.costz+"'></input>";
$("#nursinglevel_description").append(input);
$("#nursinglevel_expenses").append(input2);
$("#cost").append(input2);
$("#costz").append(input2);
$("#nursinglevel_description").fadeIn("slow");
$("#nursinglevel_expenses").fadeIn("slow");
$("#cost").fadeIn("slow");
$("#costz").fadeIn("slow");
},
error:function(){
alert("请求失败")
}
});
});
<div class="control-group">
<label class="control-label" for="name">护理级别:</label>
<select class="form-control" id="nursinglevel_object" >
<option >请选择护理级别</option>
<c:forEach items="${nursinglevel2}" var="listone">
<option value="${listone.nursinglevel_object}">${listone.nursinglevel_object}</option>
</c:forEach>
</select>
</div>
<div class="control-group">
<label class="control-label" for="name"> 级别说明:</label>
<input type="test" readonly="true" id="nursinglevel_description" data-getDataUrl="<%=basePath %>Nursinglevel/selNursinglevelall" class="form-control" value="${nursinglevel1.nursinglevel_description}">
</div>
<div class="control-group">
<label class="control-label" for="name"> 护理级别费用:</label>
<input type="test" readonly="true" id="nursinglevel_expenses" class="form-control" value="${nursinglevel1.nursinglevel_expenses}">
</div>
<div class="control-group">
<label class="control-label" for="name">私人定制费用:</label>
<input type="test" id="cost" readonly="true" class="form-control" value="${nursinglevel1.cost}">
</div>
<div class="control-group">
<label class="control-label" for="name"> 护理总费用:</label>
<input type="test" id="costz" readonly="true" class="form-control" value="${nursinglevel1.costz}">
</div>
...全文
187 1 点赞 打赏 收藏 举报
写回复
1 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
peng2739956 2017-11-16
报错很明显 写着 head is null or 找不到
  • 打赏
  • 举报
回复
相关推荐
发帖
.NET社区
加入

5.9w+

社区成员

.NET技术交流专区
申请成为版主
帖子事件
创建了帖子
2017-11-15 08:36
社区公告
暂无公告