Hello everyone,
-
- jQuery(document).on("change", ".chkclass", function () {
- var id ="";
- $('input[class="chkclass"]').each(function (e) {
-
- if (this.checked) {
- id = id + $(this).val()+',';
- }
- });
-
- function SaveSelecteItems(id) {
-
- $.ajax({
- type: "POST",
- url: "/YourControllerName/YourAddMethodName/",
- data: JSON.stringify({
- id: id.toString();
- }),
- contentType: "application/json; charset=utf-8",
- dataType: "json",
- async: false,
- success: function (result) {
- alert('Successfully Saved!!!')
- }
- });
-
- }
- });
Then inside controller - public ActionResult SmartSaveCheckedItems(string id)
- {
- var eachId = id.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).Distinct();
- foreach (var item in eachId)
- {
-
- }
- }