1.
function doSave() {
ajax_get("${contextPath}/auth/functionsave", $("#editForm").serialize(), function(data) {
if (data.errorMessage) {
showmsg(0, data.errorMessage);
} else {
showmsg(1, "处理成功!");
}
});
}
2.跳出窗口
funFrame.location.href="${contextPath}/auth/functionform?id="+treeNode.id;
3.
ffunction ajaxFileUpload(id) {
var uploadUrl = encodeURI(encodeURI("${contextPath}/commons/uploadimgs"));
if (uploadUrl != "") {
$.ajaxFileUpload({
url : uploadUrl,
secureuri : false,
fileElementId : ‘uploadfile‘ + id,
dataType : ‘text‘,
success : function(data, status) {
var dataset = jQuery.parseJSON(jQuery(data).text());
if (dataset.ret == "ok") {
if (id == 0) {
$("#sicon").attr("src", dataset.url);
$("#icon").val(dataset.url);
//alert(1);
} else if (id == 1) {
$("#smicon").attr("src", dataset.url);
$("#micon").val(dataset.url);
} else if (id == 2) {
$("#sbicon").attr("src", dataset.url);
$("#bicon").val(dataset.url);
}
} else if (dataset.ret == "empty") {
showmsg(0, ‘没有选择图片,请先选择图片!‘);
} else {
shomsg(0, ‘图片上传失败,请重试!!‘);
}
},
error : function(data, status, e) {
console.log(e);
console.log(data);
showmsg(0, ‘图片上传失败,请重试!!‘);
}
});
}
}
4.
$.ajax({
url : "${contextPath}/web/createproject1.htm",
data : $("#editForm").serialize(),
cache : false,
success : function(xmlHttp) {
var res = xmlHttp;
if (res.errorMessage && res.errorMessage != "") {
showmsg(0, res.errorMessage);
} else {
location.href = "${contextPath}/web/tocreateproject2.htm?projectid="+ res.llong;
}
}
});
4.ajax 动态传值 (同一个页面中)
<a href="#" onclick="getRightInfo(${v.ctid})"></a>
<div id="rightinfo"></div>
<script type="text/javascript">
$(document).ready(function() {
});
function getRightInfo(ctid) {
$.ajax({
url : "${contextPath}/web/infoshoplist.htm",
data : "ctid="+ctid,
cache : false,
success : getRightInfoCallback
});
}
function getRightInfoCallback(xmlHttp) {
var mainfloor = xmlHttp.infoshoplist;
if (mainfloor != null) {
$("#rightinfo").hide();
var str = ‘‘;
for (var i = 0; i < mainfloor.length; i++) {
str += ‘<a href="${contextPath}/web/infoshop.htm?shopid=‘ + mainfloor[i].shopid + ‘">‘;
str += ‘<div class="media">‘;
str += ‘<div class="A">‘;
str += ‘<div class="media-left">‘;
str += ‘<img class="media-object" src="${contextPath}/resources/‘ + mainfloor[i].icon + ‘">‘;
str += ‘</div>‘;
str += ‘<div class="media-body">‘;
str += ‘姓名:‘+ mainfloor[i].username;
str += ‘<br>‘;
str += ‘标签:‘+ mainfloor[i].ctname;
str += ‘<br>‘;
str += ‘店铺:‘+ mainfloor[i].shopname;
str += ‘</div>‘;
str += ‘</div>‘;
str += ‘</div>‘;
str += ‘</a>‘;
}
$("#rightinfo").html(str);
$("#rightinfo").show();
} else {
$("#rightinfo").hide();
}
}
</script>
@RequestMapping("/infoshoplist.htm")
@ResponseBody
public Map<String, Object> infoshoplist(Model model, RequestParameter param) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("infoshoplist", webService.getInfoShopList(param.getCtid()));
return map;
}