TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Madhav Sharma
882
899
38.9k
Facing issue in Ajax call
May 5 2020 9:46 AM
Facing issue in Ajax call
I am passing the array in ajax call but url does not hit on controller why it is happening can some one help
//
$(document).on('click', '#btnUpdate', function () {
var arr = new Array();
var table = $("table tbody");
table.find('tr').each(function (i) {
var obj = {};
//obj.tds = $(this).find('td');
debugger;
obj.FranchiseId = $('select#franchiseId option:selected').val();
obj.ItemCategoryId = $('select#categoryId option:selected').val();
obj.ItemName = $(this).find('td:eq(0) input').val();
obj.Quantity = $(this).find('td:eq(1) input').val();
obj.SupplyPurchaseValue = $(this).find('td:eq(2) option:selected').text();
//obj.SupplyPurchaseValue = $(this).find('td').eq(2).text();
obj.Remarks = $(this).find('td:eq(3) input').val();
arr.push(obj);
});
var postData = { values: arr };
debugger;
var ServiceUrl = '@Url.Action("UpdateItems","ItemList")';
//var abc = "amit";
$.ajax({
type: 'POST',
url: ServiceUrl,
//data: JSON.stringify({myObj: obj}),
//data: { obj: obj },
//data: { '': obj },
data: postData,
traditional: true,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (obj) {
debugger;
alert(data);
}
});
});
Conrroller Code
[HttpPost]
public JsonResult UpdateItems(List<ItemUpdateViewModel> data)
{
var res = new JsonMessage();
res = repo_itemlist.SaveAndUpdateItems(data);
//return View(data,);
return Json(res, JsonRequestBehavior.AllowGet);
}
Reply
Answers (
6
)
How to avoid the second screen when i am hitting Delete butt
action method (link) not working after publish my project