<script type="text/javascript"> function GetTime() { $.get("Home/GetTime", function (response) { $("#myPnl").html(response); }); return false; } </script> <div id="myPnl" style="width: 300px; height: 30px; border: 1px dotted silver;"> </div> <a href="#" onclick="return GetTime();">Click Me</a> public ActionResult GetTime() { return Content(DateTime.Now.ToString()); } //删除 function DeleteAll(id) { //if ($(":checkbox[name=‘checkbox_app‘]:checked").size() == 0) { // alert("您没有选择要删除的数据!"); return; //} if (!confirm(‘您真的要删除所选应用吗?‘)) { return false; } //var id = ""; //var box = ""; //$("input[name=‘checkbox_app‘]:checked").each(function () { // box = $(this); // id = box.val(); //}); $.ajax({ url: "/Home/DeleteIWFAll/" + id, type: "post", success: function (data) { if (data.success == true) { //box.parent().remove(); alert("删除成功!"); reloadiframe("tab_" + appid.replace("-", "") + "_iframe"); $("#searchform").submit(); } else { alert("删除成功失败!") return false; } }, error: function (err) { alert("删除成功失败!") return false; } }); public JsonResult DeleteIWFAll(string id) { JsonResult json = new JsonResult(); //调用删除方法 int count = PC_InnovationPointBLL.DeleteIWFAll(id); if (count > 0) { json.Data = new { success = true }; } else { json.Data = new { success = false }; } return json; } function Filter() { $("#isSearch").val("true"); $("#searchform").attr("action", "/Home/[email protected](ViewBag.Query)&AppName=" + AppName + "&tabid=" + ‘@ViewBag.tabid‘ + "&flowname=" + flowname); $("#searchform").submit(); }
document.onkeydown = function (event) { var e = event || window.event || arguments.callee.caller.arguments[0]; if (e && e.keyCode == 13) { // enter 键 //要做的事情 $("#isSearch").val("true"); $("#searchform").attr("action", "/Home/[email protected](ViewBag.Query)&AppName=" + AppName + "&tabid" + ‘@ViewBag.tabid‘ + "&flowname=" + flowname);
$(‘#searchform‘).submit(); } }
通过post方法实现Form的Ajax提交
<script type="text/javascript"> $(function () { $("#Button1").click(function () { //验证内容 if ($("#Menutype").val() == ‘‘) { alert("所属类型不能为空"); return false; } if ($("#MenuName").val() == "") { alert("菜单名称不能为空"); return false; } //提交 $("#mainForm").submit(); }); }); </script> <form action="/Home/Index" method="post" id="mainForm"> <table id="MemberArea"> <thead> <tr> <td colspan="2"> <h3> 新增菜单</h3> </td> </tr> </thead> <tbody> <tr> <td> 所属类型 </td> <td> @Html.TextBox("Menutype") </td> </tr> <tr> <td> 菜单名称 </td> <td> @Html.TextBox("MenuName") </td> </tr> <tr> <td> 连接地址 </td> <td> @Html.TextBox("URL") </td> </tr> <tr> <td>目标框架</td> <td> @Html.TextBox("TarGetFrame")</td> </tr> <tr> <td> 图标名称</td> <td> @Html.TextBox("ICON")</td> </tr> <tr> <td>权限名称</td> <td> @Html.TextBox("PerMIssionName")</td> </tr> <tr> <td>权限表示</td> <td> @Html.TextBox("PerMIssionId")</td> </tr> <tr> <td>类型排序</td> <td> @Html.TextBox("Orders")</td> </tr> <tr> <td>说名</td> <td>@Html.TextBox("DescriptIon")</td> </tr> <tr> <td colspan="2"> <input type="button" id="Button1" value="Index" /> </td> </tr> </tbody> </table> </form> Controllers [HttpPost] public ActionResult Index(Maticsoft.Model.Menu model) { //SelectList selectNameList = new SelectList("123");//构造一个下拉列表的键值对 //ViewData["Menutype"] = selectNameList; model.id=model.id +=1; menu.Add(model); // ViewData["Message"] = "添加成功!"; return View(model); }
时间: 2024-10-07 09:04:13