I have a data table created with jquery. I have a jquery code to get the id of the row I selected from this table. According to this id, I make transactions from the database and create a pdf file. But when I say "download" the pdf file I created, my code doesn't work.
My "PDF İndir" button code
<a class="btn btn-sm btn-info pull-right" onclick="PDFIndir('/Raporlama/PdfIndir/', this)" id="btnPdf"><i class="fa fa-file-pdf-o"></i>  PDF İndir</a>
My "PdfIndir jquery code
function PDFIndir(urlx,t)
{
   var id = $(t).parents(".ui-dialog").find("table").attr("id");
   var seciliid;
   $("#"+id+" tbody tr.selected").each(function(){  
       seciliid = ($(t).parents(".ui-dialog").find(".ui-dialog- 
       content").find("table").DataTable().row($(this)).data().id);
   });
   $.ajax({
       type:"GET",
       url:urlx,
       data:seciliid
   });
}
My ActionResult code
    public ActionResult PdfIndir()
    {
        var id = new Guid(Request.QueryString.ToString());
        MemoryStream str = new MemoryStream();
        Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
        using (StringWriter sw = new StringWriter())
        {
            using (HtmlTextWriter hw = new HtmlTextWriter(sw))
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("<table width='100%' cellspacing='0' cellpadding='2'>");
                sb.Append("<tr><td style='background-color:#ffffff; width: 100%;' colspan='2'><img src='C:/TfsProject/Atm/atm.server.ui/images/at4.png' /></td></tr>");
                sb.Append("<tr><td><b>ABONE NO: </b>");
                sb.Append(aboneNo);
                sb.Append("</td><td align='right'><b>TARIH: </b>");
                sb.Append(DateTime.Now);
                sb.Append("</td></tr>");
                sb.Append("<tr><td colspan='2'><b>ABONE ADI: </b>");
                sb.Append(ad);
                sb.Append("</td></tr>");
                sb.Append("</table>");
                sb.Append("<br />");
                StringReader sr = new StringReader(sb.ToString());
                HTMLWorker parse = new HTMLWorker(pdfDoc);
                PdfWriter writer = PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
                pdfDoc.Open();
                parse.Parse(sr);
                pdfDoc.Close();
                this.Response.ContentType = "application/octet-stream";
                this.Response.AddHeader("content-disposition", "attachment;filename=" + dosyaAdi + ".pdf");
                this.Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
                this.Response.Write(pdfDoc);
                this.Response.End();
                return View();
            }
        }
    }
