Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

jquery get selected checkbox items and pass to parameter for C# MVC consumption

var checkItems = $('[name="checkbox"]:checked');
            var combines = [];
            $.each(checkItems, function (i, arqs) {
                combines.push($(this).attr('data-combine'));
           });
            var param = {
                'cmbinedata': combines
            }
          
              $.ajax({
                url: '@Url.Action("YourMethodName", "YourCOntrollerName")',
                data: JSON.stringify(param),
                type: "POST",
                dataType: "json",
                contentType: 'application/json; charset=utf-8',
                success: function (result) {
                      //do something
                },
                error: function (err) {
                    tata.error('Error', "Error !!!");
                    location.reload();
                }
            });
Source by edwindeloso.com #
 
PREVIOUS NEXT
Tagged: #jquery #selected #checkbox #items #pass #parameter #MVC #consumption
ADD COMMENT
Topic
Name
9+6 =