相关疑难解决方法(0)

ASP.NET网页(WebMatrix)发布的jQuery帖子

我正在尝试使用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>
Run Code Online (Sandbox Code Playgroud)

如何将值从表单传递给Request.Form对象?而且我怎么能回应json回到html?

asp.net ajax jquery post webmatrix

5
推荐指数
2
解决办法
1578
查看次数

标签 统计

ajax ×1

asp.net ×1

jquery ×1

post ×1

webmatrix ×1