相关疑难解决方法(0)

将json数据发送到ASP.NET WebMethod的jquery问题

我已经阅读了有关此问题的所有问题,但没有设法解决它...

分数类:

public class Score
{
    // default constructor
    public Score()
    { }

    public int TraitID { get; set; }

    public double TraitScore { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

ASPX WebMethod:

    [WebMethod]
    public static bool Test(List<Score> scores)
    {
        return true;
    }
Run Code Online (Sandbox Code Playgroud)

jQuery代码:

            var scoresList = [{"TraitID":1,"TraitScore":2}, {"TraitID":2,"TraitScore":5}];

            $.ajax({
                type: "POST",
                url: "Tryouts.aspx/Test",
                data: "{'scores':" + JSON.stringify(scoresList) + "}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (response) {
                    if (response.d == true) {
                        alert("success!!!!!");
                    }
                    else {
                        alert("problem!!!!!!!!!");
                    }
                },
                error: function …
Run Code Online (Sandbox Code Playgroud)

asp.net ajax jquery json

4
推荐指数
1
解决办法
8581
查看次数

标签 统计

ajax ×1

asp.net ×1

jquery ×1

json ×1