S
S
Saharman2018-03-29 03:06:20
ASP.NET
Saharman, 2018-03-29 03:06:20

Why is the data not being passed to the controller?

I have this script:

<script type="text/javascript">
        $(function () {
            $("input:checkbox").click(function () {
                $.ajax({
                    type: 'POST',
                    url: '/Project/Index/',
                    dataType: "html",
                    data: "Hello",
                });
            });
        })
    </script>

And there is this controller:
[HttpPost]
        public ActionResult Index(string stat)
        {
            return View();
        }

I checked in the debugger, we get into this controller, but stat is null. In what there can be a business and how to solve?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
lam0x86, 2018-03-29
@lam0x86

I haven't dealt with ASP.NET for a hundred years, but I suppose that if you write in the front-end:
then everything will work.

E
eRKa, 2018-04-17
@kttotto

Try this
. Well, of course, the object should be sentdata: { stat: "Hello" }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question