开发者

$.post in a each loop ASP.NET MVC

开发者 https://www.devze.com 2022-12-11 05:31 出处:网络
Have some simple jquery that Im trying to execute on a button click. For some reason it is not working. It \"posts\" the first element with class of \'editable\' but not any others. I have about 9 ele

Have some simple jquery that Im trying to execute on a button click. For some reason it is not working. It "posts" the first element with class of 'editable' but not any others. I have about 9 elements in DOM that is should be looping through.

I taken a look with firebug at each post request and like I said the first is ok, but then the rest come back and '500 Internal Server Error'.

Below is my code, any ideas here?

$(".editable").each(function() {
            if (this.id != '') {
                //save content of each item
                $.post("/DynamicContent/SaveContent", { hid: this.i开发者_如何学Cd, content: $(this).html() }, function(data) {
                    alert(data);
                });

            }
        });


You're probably getting a HttpRequestValidationException from posting unencoded html. See How to avoid HttpRequestValidationException in ASP.NET MVC rendering the same view which caused the exception

0

精彩评论

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