ASP.NET网页(WebMatrix)发布的jQuery帖子
发布时间:2020-12-16 07:15:25 所属栏目:asp.Net 来源:网络整理
导读:我正在尝试使用jQuery提交表单数据.我正在使用ASP.NET WebMatrix.在我的.cshtml文件中 @{ // other code if(IsPost) { var item = new Item(); item.Title = Request.Form["title"]; item.Description = Request.Form["description"]; // aditional code her
我正在尝试使用jQuery提交表单数据.我正在使用ASP.NET WebMatrix.在我的.cshtml文件中
@{ // other code if(IsPost) { var item = new Item(); item.Title = Request.Form["title"]; item.Description = Request.Form["description"]; // aditional code here } } <script type="text/javascript"> $(document).ready(function(){ $("form#itemForm").submit(function(){ $.post("form.cshtml",{ title: $("#title").val(),description: $("#description").val(),price: $("#price").val()},function(data){ },"json"); }) }); </script> <form> <!-- html form here --> </form> 如何将值从表单传递给Request.Form对象?而且我怎么能回应json回到html? 解决方法
更好的方法是让jQuery使用$(this).serialize()发布表单数据,而不是构建一个包含它的所有值的对象.之后,yah,Request [“title”]等将获得已发布的值.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – 如何在Azure应用服务中管理(非SSL)证书?
- asp.net-mvc – 如何从ASP.NET MVC的部分视图中获取用户(IP
- asp.net核心,角度2,PrimeNG
- asp.net – 没有找到WebResource.axd
- asp.net-mvc – 使用表单身份验证在ASP.NET MVC上存储登录的
- iis-7.5 – ASP.NET 5将应用程序添加为IIS应用程序
- asp.net-mvc – 在ASP.NET MVC应用程序中放置数据操作和业务
- asp.net – 连接字符串最佳实践
- asp.net – 未定义Page_ClientValidate
- asp.net – 403从WindowsAzure.Storage生产错误