Can I make an Ajax Call to my Controller and Action method to get some data, from a HTML page instead of CSHTML page. I have exactly the same content but instead of cshtml, I want to use a HTML page.
If Yes, please give me a sample code.
EDIT The Actual Problem was different and I'm sorry for being unclear About it.
The Actual problem is I'm trying to generate a PDF using Rotativa. And i wanted to add a footer to it and it contains some dynamic part.
string header = System.IO.Path.Combine(HostingEnvironment.ContentRootPath, "Views/Home/header2.html");
string footer = System.IO.Path.Combine(HostingEnvironment.ContentRootPath, "Views/Home/Footer.html");
string customSwitches = string.Format("--header-html \"{0}\" " +
//"--header-spacing \"0\" " +
"--page-offset 0 --header-right \"Page: [page] of [toPage]\" " +
"--footer-html \"{1}\" " +
"--footer-spacing \"10\" " +
//"--footer-font-size \"10\" " +
"--header-font-size \"10\" ", header, footer);
var pdfResult = new ActionAsPdf("CreatePDF1", headerData)
{
FileName = "quotation.pdf",
PageOrientation = Orientation.Portrait,
PageSize = Size.A4,
CustomSwitches = customSwitches
};
The Following is my Footer.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
<link rel="stylesheet" href="~/css/site.css" />
<link rel="icon" href="~/Assets/Images/logo.png" />
<link href="~/css/cupertino/jquery-ui.css" rel="stylesheet" />
<link href="~/css/cupertino/theme.css" rel="stylesheet" />
<script src="~/js/jquery-2.1.3.js"></script>
<script src="~/js/jquery-ui-1.11.3.js" type="text/javascript"></script>
</head>
<body>
<div id='divContent'></div>
</body>
</html>
<script>
$.ajax({
url: "/Quotation/ReturnFooterData",
type: 'get',
async: false,
success: function (data) {
document.getElementById("divContent").innerHTML = data;
},
error: function (data) {
document.getElementById("divContent").innerHTML = "error";
}
});
</script>
That part data should be present in the PDF at the footer. Here the ajax call what I make doesn't hit the action method.
This was my actual problem, and my apologies for not providing the exact information about the problem.