开发者

ajax call to C# method not working

I want to call a method in C# from a client side AJAX/JQuery message. The client code is:

        function TestClickFunc(userId) {

            $.ajax({
                url: "/Users/UpdateEmailDistributionListFlag",
                type: "POST",
                data: { "userId" :  userId },
                success: function (data) { alert(data); }
            });

        }

This method gets called with th开发者_如何学编程e correct parameter. However in my UsersController, this method does not get called;

   [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult UpdateEmailDistributionListFlag(int userId)
    {
        // db update
        return View();
    }

Can you see why?


Check if you have a route with parameter userId. In the default route the parameter's name is id, not userId so your method will not be found.


What I found was that the CDN was not working;

I can't see the spelling mistake, but it worked when I used my local script!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜