I want to send HTML of textarea
(TinyMCE) but the input parameter is empty.
What do I missing to make it working? Any clue?
$('#btnCreateContent').click(function () {
// Checking whether FormData is available in browser
if (window.FormData !== undefined) {
var fileUpload = $("#FileUpload1").get(0);
var files = fileUpload.files;
// Create FormData object
var fileData = new FormData();
// Looping over all files and add it to FormData object
for (var i = 0; i < files.length; i++) {
fileData.append(files[i].name, files[i]);
}
// Adding one more key to FormData object
fileData.append('englishTitle', $("#inputEnglishTitle").val());
fileData.append('englishContent', $("#editorEnglishContentCreate").val());
fileData.append('spanishTitle', $("#inputSpanishTitle").val());
fileData.append('spanishContent', $("#editorSpanishContentCreate").val());
$.ajax({
url: '@Url.Action("CreateContent", "Content")',
type: "POST",
contentType: false, // Not to set any content header
processData: false, // Not to process data
data: fileData,
success: function (data) {
},
error: function (err) {
alert(err.statusText);
}
});
} else {
alert("FormData is not supported.");
}
});
//
C#
[HttpPost]
public JsonResult CreateContent(string englishTitle, string englishContent, string spanishTitle, string spanishContent)
{
// englishContent is empty :(
#editorEnglishContentCreate
have a value that is not an empty string when$.ajax()
is called?var content = editorInstance.getContent()
orgetData()
or similar