I am using tiny mce. I want to get the html elements from the textarea of tiny mce. I try to do tat with a ajax call. And I have a pdf button that will generate from the html a PDF. I have this:
public ActionResult GeneratePDFFOrProductHandler(EditProductModel model, string data)
{
SubmittedForm sf = new SubmittedForm();
string schema = requestSchema;
customer_DbConnection db = new customer_DbConnection();
RenderFormController renderController = new RenderFormController();
renderController.GeneratePdf(data, db, sf);
return RedirectToAction(model.DesignId, "Prdocut/Edit");
//return View(model);
}
and the ajax call:
function GenerateHTMLTOPDF() {
$.ajax({
type: "POST",
url: '@Url.Action("GeneratePDFFOrProductHandler", "Product")',
data: {},
success: function (data) {
alert(tinyMCE.get('tinymce').getContent());
alert("data from ajax = " + data.toString()); // data is html
$("#tinymce").html(data); // does not set anything
},
error: function (request, status, error) {
alert(tinyMCE.activeEditor.getContent());
alert(request.responseText);
}
});
}
The method in the controller is called. But data is every time null.
Thank you
For the button that Generate PDF is this:
<button type="submit" value="GeneratePDFFOrProductHandler" id="btnGeneratePDF" onclick="GenerateHTMLTOPDF()" class="btn btn-success"><i class="fa fa-fw fa-check"></i> @Resources.Action.Navigation.GeneratePDF</button>
But how to generate the pdf in a new tab of the browser?
Thank you
But If I try this:
function GenerateHTMLTOPDF() {
var data = tinyMCE.get('tinymce').getContent();
$.ajax({
type: "POST",
url: '@Url.Action("GeneratePDFFOrProductHandler", "Product")',
data: {data:data},
success: function (data) {
alert('success');
alert("data from ajax = " + data.toString()); // data is html
},
error: function (request, status, error) {
alert(tinyMCE.activeEditor.getContent());
alert(request.responseText);
}
});
}
the controller method is even not called