0

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.id, content: $(this).html() }, function(data) {
                    alert(data);
                });

            }
        });
1
  • Upon further investigation, I removed the .html() from the content property, and everything seems to be posting to the controller fine now. the html() must be causing some sort of issue here..... Commented Nov 14, 2009 at 17:36

1 Answer 1

0

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

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

2 Comments

Mauricio, thanks! This seems to be my issue, should i encode the HTML? Probably a safer bet right?
accepting html is not trivial, see google.com/search?q=xss+asp.net+mvc

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.