从ASP.NET网页jQuery的岗位(WebMatrix中) [英] jQuery post from ASP.NET web page (WebMatrix)

查看:100
本文介绍了从ASP.NET网页jQuery的岗位(WebMatrix中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用jQuery提交表单数据。我使用ASP.NET WebMatrix中。在.cshtml文件,我有

I'm trying to submit form data with jQuery. I'm using ASP.NET WebMatrix. In a .cshtml file I have

@{
    // 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?

How can I pass values from form to Request.Form object? And how can I than response with json back to html?

推荐答案

值是通过jQuery.post()传递给Request.Parameters。

Values are passed through jQuery.post() to Request.Parameters.

这篇关于从ASP.NET网页jQuery的岗位(WebMatrix中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆