是否可以使用Node.js在服务器端使用jQuery选择器/ DOM操作?
我正在尝试在我的JSP文件中插入以下代码段
{
$.ajaxSetup({
cache: false,
async: false
});
var ajax_load = "loading data please wait...";
var loadUrl = "abc.jsp";
$("#seoarea").html(ajax_load).load(loadUrl, {
param1: holdvalue1,
param2: holdvalue2
});
}
Run Code Online (Sandbox Code Playgroud)
在mozilla firfox上运行此命令时,抛出“ $ .ajaxSetup不是函数”错误。
我是 .NET 新手,我想打开一个模式弹出窗口,然后将此数据保存到数据库而不重新加载页面。
首先,用户需要单击一个按钮。Modal是通过ajax加载的。用户填写表格,然后内容经过验证并发布到数据库中。
这是按钮的代码:
<button class="btn btn-primary" asp-controller="Positions" asp-action="Create"
data-toggle="ajax-modal" data-target="#add-contact">Add new Positions</button>
Run Code Online (Sandbox Code Playgroud)
这是控制器:
// GET: Positions/Create
public IActionResult Create()
{
return View();
}
// POST: Positions/Create
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("PositionId,PositionName")] Position position)
{
if (ModelState.IsValid)
{
_context.Add(position);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
return View(position);
}
Run Code Online (Sandbox Code Playgroud)
这是模型(很简单)
public class Position
{
[Key]
public int PositionId { get; set; }
public string PositionName { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
这是我的观点的代码:
@model Models.Position
@{
ViewData["Title"] = "Create";
}
<h3>Create Position</h3> …Run Code Online (Sandbox Code Playgroud)