问题标签 [unobtrusive-ajax]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
asp.net - JSON.parse 错误:项目发布后出现意外字符
在我看来,我使用了 jquery.unobtrusive-ajax。在这个视图中,有一个表单是通过 ajax 提交的。
在模型集无效的动作中,我将通过下面的代码返回错误
在下面的代码视图中,我向用户显示了错误。
SyntaxError:JSON.parse:JSON 数据的第 1 行第 1 列出现意外字符
asp.net-core - Razor Pages ASP.NET 不显眼的 ajax 发布部分更新
我正在尝试从部分视图中仅更新部分页面。如果我使用它,它工作得很好
但这是一个简单的获取,我想实际发布一些数据并用它做一些事情。我写了一个表单,将它的方法设置为像这样发布。
但是这会更新我的整个页面,所以我的整个页面只是应该更新的部分视图。
c# - 如何在选择列表中进行不显眼的 Ajax 调用?
我试图在我的应用程序中设置一个下拉菜单,允许用户根据它是否被归类为 PII 来选择元数据列表。我遇到的问题是如何本质上将@Ajax.ActionLink() 背后的逻辑合并到我的选项结果中并在不导航到局部视图的情况下执行它们(因为我希望它显示在当前页面中)。
查看页面:
我将不胜感激任何反馈。
c# - 重新初始化不显眼的 jquery 验证
我已经通过 ajax 重新绑定视图模型,因为我不喜欢默认的功能模式弹出窗口,因为我忘记了我正在关注的教程链接,这是我的一些代码
数据表代码
部分编辑表单
和控制器代码
视图模型
问题是,重新绑定部分视图后,强制验证始终为真,重新绑定后所需的验证不起作用
编辑:我试过 .validate() 和 .valid()
它总是返回 true,即使文本框为空
asp.net-mvc - Ajax.BeginForm Post 无法绑定 PartialView 中的对象列表
我正在尝试设置一个显示对象列表的 PartialView,其中包含最终用户将检查的布尔属性。提交后,PartialView 应该执行 AJAX POST,以便将该对象列表传递给另一个 PartialViewResult 并在同一页面上显示另一个 PartialView。
但是,我的控制器正在获取该列表的空值。我该如何解决?
简单示例:
看法:
部分视图一:
模型:
.net-core - .Net Core 3.0 AJAX POST 正文始终为空
我最近将我的项目从 .Net Framework 4.7 转换为 .Net Core 3.0。我无法让我的 AJAX 帖子正常工作。
以下是 .Net Framework 4.7 的工作原理:
看法:
控制器:
以下是 .Net Core 3.0 中不起作用的内容:
看法:
控制器:
Contract 对象在此请求中为 NULL。有什么我做错了吗?
谢谢
c# - Using ValidateAntiForgeryToken attribute with Unobtrusive Ajax plugin in ASP.NET Core
I have the following form:
(Yes, I do realize that I'm kind of mixing Unobtrusive AJAX syntax with ASP.NET Core tag helpers).
I have the following Action Method in my controller:
This works just fine, unless I uncomment the ValidateAntiForgeryToken
attribute.
I've seen examples of doing validation for jQuery AJAX calls, but many of those rely on sending it in the headers (e.g. in this Q&A). Supposedly, this will make the ValidateAntiForgeryToken
just work as expected (with a few configuration changes in code). Hopefully I'm not missing something obvious, but I've searched quite a bit and can't find how to actually add a header in Unobtrusive AJAX, so I haven't even be able to try something like that to see if it would work.
I know that you can do User.IsInRole("RoleName")
as an alternative to the Authorize
attribute. Is there a way to send the Anti-Forgery Token as a parameter and do it that way? Or is there a way to edit the headers and do it that way? Or is there a better way to do this that I haven't thought of yet?
In general, is there some way to edit the Ajax call before it's sent?
c# - 在 Razor 页面中使用 Unobtrusive AJAX 时,一个表单中可以有 2 个按钮吗?
我在表单的 PageModel 中有 2 个 OnPost 处理程序,有没有办法在每个按钮上使用不同的 post 处理程序运行 Unobtrusive AJAX?我似乎在这方面找不到任何东西。或者有没有更好的方法通过 JQuery 实现这一点?
两个处理程序似乎都在执行正确的功能,但我只能运行当前使用此方法的一个或另一个。
这是我所拥有的:
感谢您提供任何信息!
asp.net-core - Ajax 按钮引发此错误:- 服务器未找到与请求的 URI(统一资源标识符)匹配的任何内容
我正在开发一个 Asp.Net MVC 核心 Web 应用程序,并且我在我的 razor 视图中添加了以下表单,以构建一个 Ajax 表单:-
我在脚本中添加了以下内容:-
但是当我单击提交按钮时,我在浏览器控制台上收到此错误:-
有什么建议吗?
jquery - 动态表单 ajax beginform 验证错误 - MVC
实施细节:
- 页面有添加按钮和表格视图
- 单击添加按钮时,部分视图(表单)会加载到 Modal PopUp 上。根据参数选择的动态形式。
- 在添加按钮上单击下面的代码用于将部分视图表单绑定到 div
- 使用实现的部分视图表单
问题: - 单击保存验证时未触发。
其他信息:
脚本文件:
我尝试在 ajax 成功方法中添加以下代码
出现以下错误:
提前感谢您的帮助。