1

I am doing ajax call to update data like below:

self.UpdateStatus = function () {
    $.ajax({
        type: "POST",
        url: 'Test.aspx/UpdateStatus',
         data: ko.toJSON({ data: self.Goals }),
        contentType: "application/json; charset=utf-8",
        success: function (result) {
            var resHTML = result.d;
            if (resHTML != "") {
                alert(result.d);
            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert(textStatus);
            alert(errorThrown);
        }
    });
    return true;
};

Where Task is my observable array.This is my task Array:

function Goals(d) {
    this.GoalID = ko.observable(d.GoalID);
    this.Goal = ko.observable(d.Goal);
    this.Note = ko.observable(d.Note);
    this.Status = ko.observable(d.Status);
}

My update method header is like below

public static bool UpdateStatus(Goals[] goal)
//query to update status of a goal
        string sqlUpdateStatus = @"UPDATE M_USERGOAL_INFO 
                                        SET STATUS = true 
                                  WHERE PK_ID = " + **goal[].GoalID**;

Where Goal is my class name. But its showing me error(client side): Internal server error Message":"Invalid JSON primitive: I am confused here whether i should pass that array here or variable(more than one in my case). Errror picture

4

0 回答 0