Reputation: 27021
I have the below code in my MVC view which gets the contents of a TextArea control and makes a request to a url (action) then displays the result in another text box:
var input = $('#tbInput').val(); // it can have some invalid characters such as +, #, etc
var encodedInput = // how?;
$.ajax({
url: url,
success: function (data) {
alert(data);
$('#tbResult').html(data);
},
error: function (request, status, error) {
alert('An error occured: ' + error);
},
cache: false
});
If I only send the input data, the invalid characters are just removed so I'd need to html encode the text then sending it?
The input should appear as below:
Thanks,
Upvotes: 1
Views: 487
Reputation: 888303
Let jQuery do that:
$.ajax({
url: url,
data: { something: input },
Upvotes: 1