Dinesh
Dinesh

Reputation: 1007

json passing function is not working in jquery

i pass json value my controller is working i checked my controller using break points but my json is not working it didn't responding alert message also not working please some one helpme friends. . .

My jquery

  $('#Group').change(function () {
            var name = $('#Tournament').val();   

            $.post("/DataCollection/Fee", { name: name, group: $('#Group').val() }, function (result) {
                alert('hai');
                $('#Fee').val(result.value.Fees);
                $('#Count').val(result.value.NoOfboys);
                $('#CName').empty();
                $('#CName').append($("<option></option>").html("--SELECT--"));
                $.each(result.Cname, function (key, value) {
                    $('#CName').append($("<option></option>").html(value).val(value));
                });

            }, "json");
        });

My Controller

     public JsonResult Fee(string name, string Group)
    {            
        var value = entity.TblClsGroups.FirstOrDefault(x => x.TName == name && x.GroupName == Group && x.RecordStatus == 1);
        var Cname = entity.TblGroups.Where(x=>x.RecordStatus==1 && x.TName == name && x.GroupName == Group).Select(c=>c.Cid);           
        var getFee = new { Cname, value };
        return Json(getFee, JsonRequestBehavior.AllowGet);
    }

Upvotes: 0

Views: 109

Answers (2)

Jeyhun Rahimov
Jeyhun Rahimov

Reputation: 3787

try this:

return Json(new { Cname = Cname, value = value }, JsonRequestBehavior.AllowGet);

and in view use them like result.Cname and result.value

Upvotes: 1

Andrei V
Andrei V

Reputation: 7506

Try this:

var getFee = new { Cname = Cname, value = value };

Upvotes: 0

Related Questions