1

Im using ASP.NET MVC and the kendo ui editor and jquery ajax.

Basically if I have a £ character in the kendo ui editor and post the contents to the server using ajax with this code :

$.ajax({
    url: "/API/saveContent",
    data: "content=' + escape($("#textContent").data("kendoEditor").value()),
    type: "POST", dataType: 'json', async: false,
    success: function (data) {},
    error: function () { alert('ajax error'); }
});

What I end up with on the server is a ? character rather than a £.

The html page is UTF-8, so the ajax call to the server is unicode and the javascript escape function isnt working in a unicode way, its just using the extended ascii character set and encoding the £ as : %A3

Is there a way in javascript to do this escape functionality with unicode, I think I want to end up with : %C2%A3 (i worked this out by having a UTF-8 html page and put £ in a text box and submitted the form and in fidler it showed this has been content in request body of the post).

1
  • "This post does not meet our quality standards." is pretty infuiating when it doesnt tell you what the problem is, it takes longer to "fix" the question than write it. Commented Apr 24, 2013 at 17:27

1 Answer 1

1

You should use encodeURIComponent instead of escape

data: "content=" + encodeURIComponent($("#textContent").data("kendoEditor").value()),
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks a lot, i'd seen that function before but discarded it as its name suggests its more for urls.
@Paul Well the data is being sent as application/x-www-urlencoded

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.