Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ASP.NET MVC$.ajax POST不';我不能正确地提交_Asp.net_Asp.net Mvc_Ajax - Fatal编程技术网

ASP.NET MVC$.ajax POST不';我不能正确地提交

ASP.NET MVC$.ajax POST不';我不能正确地提交,asp.net,asp.net-mvc,ajax,Asp.net,Asp.net Mvc,Ajax,在javascript中,我有以下内容: $.ajax({ url: "/ajax/test", type: "POST", dataType: "html", data: '{"keyword" : "' + $('#tbxBrand').val() + '", "projectguid" : "<%= thisProject.ProjectGuid.ToString() %>", "userguid" : "<

在javascript中,我有以下内容:

$.ajax({
        url: "/ajax/test",
        type: "POST",
        dataType: "html",
        data: '{"keyword" : "' + $('#tbxBrand').val() + '", "projectguid" : "<%= thisProject.ProjectGuid.ToString() %>", "userguid" : "<%= thisUser.UserGuid.ToString() %>"}',
        beforeSend: function() { },
        success: function(data) {
            alert(data);
        }
    });
但是,Request.Form不包含正确的键。事实上,Request.Form看起来不正确:

Request.Form = {%7b%22keyword%22+%3a+%22data%22%2c+%22projectguid%22+%3a+%22cedce659-fd91-46c8-8f69-e527a38cffc2%22%2c+%22userguid%22+%3a+%2252ff20ab-cdf1-4dae-b539-645b6bf461a7%22%7d}
我不知道这里出了什么问题。有人能帮忙吗

谢谢

我用这个

    function postComment(id) {
    var commentText = jQuery.trim($("#textbox" + id.toString()).val());

    $.post("/jQueryTests/jQueryAddMessageComment", { commentText: commentText }, function(newComment) {
        $("#divComments" + id.toString()).html(newComment);
    });
}
然后在c中#


我不使用Request.Form,因为数据应该作为参数传递给c#方法。

不要引用数据。对象将转换为查询字符串。如果使用字符串,则需要使用查询字符串格式。此外,我认为在标记周围使用单引号会更好。如果需要,这将允许您在标记内使用双引号

$.ajax({
    url: "/ajax/test",
    type: "POST",
    dataType: "html",
    data: {
           "keyword" :  $('#tbxBrand').val(),
           "projectguid" : '<%= thisProject.ProjectGuid.ToString() %>',
           "userguid" : '<%= thisUser.UserGuid.ToString() %>'
          },
    beforeSend: function() { },
    success: function(data) {
        alert(data);
    }
});
$.ajax({
url:“/ajax/test”,
类型:“POST”,
数据类型:“html”,
数据:{
“关键字”:$('#tbxBrand').val(),
“项目GUID”:“”,
“userguid”:”
},
beforeSend:function(){},
成功:功能(数据){
警报(数据);
}
});
        public ActionResult jQueryAddMessageComment(string commentText)
    {
        //postComment
        return PartialView("commentList", new FormViewModel { LastComment = commentText });
    }
$.ajax({
    url: "/ajax/test",
    type: "POST",
    dataType: "html",
    data: {
           "keyword" :  $('#tbxBrand').val(),
           "projectguid" : '<%= thisProject.ProjectGuid.ToString() %>',
           "userguid" : '<%= thisUser.UserGuid.ToString() %>'
          },
    beforeSend: function() { },
    success: function(data) {
        alert(data);
    }
});