I'm trying to post a Form through a MVC Model into a Save function in a controller. I'm also using tinymce on the client side which results a HTML code based string such like <p> Content text blah blah ...</p>
.
The problem is that I cannot post a string that includes <p> something </p>
But surprisingly, < p > something < / p >
this string (with spaces after "<") has NO problem. But, I cannot handle this html code and make these spaces before posting every time. There must be a better way.
So, How can I post a string that includes HTML code through $.post method? (If you must know, this project is a Content Management System. So, I have to save the HTML based content text into a SQL table.) I saw by debugging, the post action does not even reach to the Controller and I think this is a only javascript problem, am I right?
Here is the code I am using:
Javascript
function JqueryFromPost(formId) { var form = $(formId); var action = form.attr("action"); var serializedForm = form.serializeArray(); $.post(action, serializedForm, function (data) { //Getting the data Result here... }); }
CS Code
[HttpPost] public JsonResult SaveArticle(ArticleModel model) { JsonResult JResult = new JsonResult(); if (ModelState.IsValid) //I do the saving here ending with "JResult.Data = "Success";" (this could also be Failed. So, its just to explain) return JResult; }