Marius Vasile

Marius Vasile

  • 592
  • 1.9k
  • 145.5k

jQuery ajax post not working on IIS

Aug 21 2024 5:29 PM

I was working on an application in asp.net and on localhost was working fine. When deployed on IIS server the url in ajax post and print are not working. What I have is

<script type="text/javascript">

    $("#inputCompartiment").autocomplete({
        source: function (request, response) {
            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: "Index.a s p x/CodCompartimentGet",
                data: "{'parametru':'" + document.getElementById('inputCompartiment').value + "'}",
                dataType: "json",
                success: function (data) {
                    if (data != null) {
                        response(data.d);
                    }
                },
                error: function (result) {
                    alert("Error");
                }
            });
        }
    });

    function PrintDiv() {

        var divToPrint = document.getElementById("DivPrintCompartiment");
        var divToPrintHTML = '<style type="text/css" media="print">@page { size: landscape; }</style>' + divToPrint.outerHTML;
        var printWindow = window.open();
        printWindow.document.write('<html><head><title>Test de verificare a cunostintelor - Raport compartiment</title>');
        printWindow.document.write('<link h r e f="Style/bootstrap/css/bootstrap.min.css" rel="stylesheet" />');//external styles
        printWindow.document.write('<link h r e f="Style/cssStyle.c s s?version=9" rel="stylesheet" type="text/css" />');
        printWindow.document.write('</head><body>');
        printWindow.document.write(divToPrintHTML);
        printWindow.document.write('</body></html>');
        printWindow.document.close();

        printWindow.onload = function () {
            printWindow.focus();
            printWindow.print();
            printWindow.close();
        }
    };

    $(function () {
        $("#btnPrint_Lucrator").click(function () {
            printDataLucrator();
        });
    });
    function printDataLucrator() {
        var printContents = document.getElementById("DivPrintLucrator").innerHTML;
        var originalContents = document.body.innerHTML;
        document.body.innerHTML = printContents;
        window.print();
        document.body.innerHTML = originalContents;
    }
</script>

 


Answers (2)