views:

500

answers:

1

Hi everyone!

I'm using this to save some data to DB:

$("#btnSave").click(function() {
        $.ajax({
            type: 'POST',
            contentType: "application/x-www-form-urlencoded; charset=UTF-8",
            data: 'description=' + oEditor.GetXHTML(),
            url: '/SuperAdmin/ReceiveData/',
            success: function() {
                alert('news saved');
            }
        });
    });

"oEditor.GetXHTML" is taken from FCKEditor. And, to receive this data I have a ASP.NET MVC method (ActionResult):

public void ReceiveData(string description)
{
}

The point is: when I send, for example, this sentence include the "JavaScript Integration Module" scripts, the ReceiveData method only gets until include the ... what comes after that doesn't come.

Debugging my jQuery function above, I saw that the sentence that I'm trying to pass to the method has html encoding with &, amp; and so on. And the double quotes of the ..."JavaScript Integration Module"... is being interpretade by the ReceiveData method as a parameter, because the double quotes have the '&' in it encoding.

So, how can I transform this '& quot' to " before send to the MVC method? Or is there a way to make this method recognize this '& quot' as a character and not a parameter?

Thanks!!!

+2  A: 

Use escape(oEditor.GetXHTML()).

Daniel A. White
Hi Daniel! It worked! What is this escape method?
AndreMiranda
https://developer.mozilla.org/En/Core_JavaScript_1.5_Guide/Predefined_Functions/Escape_and_unescape_Functions
Daniel A. White