0

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);
    }

2 Answers 2

1

try this:

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

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

Sign up to request clarification or add additional context in comments.

2 Comments

Have you tried that request goes to action or not in debug? Firstly try for 1 value. if it will work, my example will work for 2 values
friend my controller is returning value correctly but in my jquery alert message is also not working
0

Try this:

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

5 Comments

Cname and value both are not same its different datas
You should set a debugger; breakpoint and inspect the returned value.
Yes it returning value
What does it return? What does the object look like? Does it have the two properties, Cname and value. Is it a Json object?
Yes friend it returning the correct value but my alert message is also not working

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.