I have a json collection and I want to send one textbox value to controller through jQuery ajax
$('#btnsave').click(function (e) {
debugger;
$.ajax({
type: "POST",
url: '/Asset/SaveAssociate',
data: "{'data':'"+JSON.stringify(allVals)+"'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
alert(data);
// var gridk = $("#grid1").data("kendoGrid");
// gridk.dataSource.read();
}
})
})
and this is my textbox value
var _assetid = $("#AssetId").val().trim();
like data: { json and assetid :assetid } can I pass like this
This is my action method
[NoCache]
public ActionResult SaveAssociate(string data, string AssetId)
{
JavaScriptSerializer json = new JavaScriptSerializer();
List<GetUserdata> myObjs = new List<GetUserdata>();
myObjs = json.Deserialize<List<GetUserdata>>(data);
for (int i = 0; i <= myObjs.Count; i++)
{
}
return Content("Hai");
}