点滴积累~
js页面取html页面的值:
<!--
给js页面传值,xxx是后台model中设置的值
-->
<input type="hidden" name="capital_id" id="capital_id" th:value="*{xxx}"/>
关于springmvc传参问题:
//新建xxx,初始页面赋值
@RequestMapping(value = "/new/{id}/{type}",method = RequestMethod.GET)
public String newEnclosure(Model model,@PathVariable("id") Integer id ,@PathVariable("type") Integer type){
Enclosure enclosure = new Enclosure();
//根据所传的值进行不同的操作
if(type==0){
enclosure.setProductType("xxx");
}else if(type==1){
enclosure.setProductType("yyy");
}
enclosure.setProductId(id);
//最后将其放入模板对象中
model.addAttribute(enclosure);
model.addAttribute("type",type);
//传至相应的html界面
return "enclosure/edit";
}
jquery的ajax请求:
$.ajax({
url: '请求路径',
type: 'POST',
//JSON.stringify(),将postdata对象转换成字符串形式
//调用ajax的时候,data属性必须这样写。必须!
data:{allData:JSON.stringify(e)},
dataType: 'json',
}).done(function (result) {
if (result.success) {
location.reload(true);
CloudAdmin.Msg.info(result.msg);
} else {
CloudAdmin.Msg.warn(result.msg);
}
});
$.ajax(...)中的内容我d理解,是从abc.php中返回一些值,这些值以json 格式返回,后面的.done()表示$.ajax()如果执行成功,则执行.done(),funtion(e) 中的e 为返回结果,如果$.ajax()执行发生错误,则.done()不执行。
前端js弹出输入框:
prompt("message","message2");message是提示语,message2是默认输入值。