This question already has answers here:
</div>
</div>
<div class="grid--cell mb0 mt4">
<a href="/questions/4759681/post-html-tag-codes-as-string-with-asp-net-mvc-jquery" dir="ltr">Post HTML tag (codes) as string with ASP.net MVC & JQuery</a>
<span class="question-originals-answer-count">
(3 answers)
</span>
</div>
<div class="grid--cell mb0 mt8">Closed <span title="2017-04-17 08:16:53Z" class="relativetime">3 years ago</span>.</div>
</div>
</aside>
So Im using TinyMCE editor and I need to post html code created.
$(".saveButton").click(function () {
var url = $(this).data('url');
var HTMLCode = tinyMCE.activeEditor.getContent();
$.ajax({
url: url,
method: 'POST',
data: { HTMLCode : HTMLCode },
success: function (data) {
//do something
},
error: function () {
toastr.error('Something went wrong.');
}
});
Im ofcourse getting 500 error because HTMLCode looks like this -
"<span class="someclass">test</span>"
Do you have any idea how to solve this ?
Serverside code
[HttpPost]
public JsonResult SaveHTML(string HTMLCode)
{
//save HTMLCode to db
return Json(new { retVal = "success" });
}
</div>