Javascript Post Data

This will post a AJAX call to the server and pass 2 items: First is an array of selected id’s and the second is a nullable int.

function updateData() {
    $.ajax({
        type: "POST",
        url: '/ControllerName/ActionName',
        datatype: "json",
        traditional: true,
        data: { ids: keys, statusID: statusID },
        success: function (data) {
            // process success here
            window.location.reload(true);
        },
        fail: function (result) {
            // process failure here
        },
    });
}

The Action on the server is as follows:

public JsonResult ActionName(List<string> ids, int? statusID)
{
    var data = "Message Retured to Client";
    return new JsonNetResult(data, JsonRequestBehavior.AllowGet);
}

Comments are closed.