Error happening going into 302

Error happening going into 302

maniyamaniya Posts: 34Questions: 8Answers: 0

Hi, I have the following jquery Code

Now the first ajax call is made properly and i get the headers back, when it reaches the ajax call of datatables i am getting 302.

No log is showing me enough information, I checked IIS logs and my Coldfusion Logs but both are empty, so it seems the issue is not with code.

$(document).on('click', '#Button',function (e) {

        e.preventDefault();

        $.ajax({
            url: "/post.cfm",
            cache: false,
            data : $('#form').serialize(),
            method: "post",
            success: function(response){

                $('div.results').show();
                $('.mytable').show();
                $('.mytable').html(response);
            }
        }).done(function(data) {

            $('#datatables').show();
            $("#datatables").DataTable({
                "bFilter": true,
                "serverSide": true,
                "deferRender":true,
                "processing": true,
                "fixedHeader": true,
                "scrollX": true,
                "columns": [
                    { "data": "CustomerName", "title": "Acccount", "autoWidth": true },
                    { "data": "flname", "title": "Completed by", "autoWidth": true,"orderable": false }
                ],
                "columnDefs": [
                    { width: 120, targets: 0 },

            { width: 90, targets: 1 }
                ],
                "fixedColumns": true,
                "ajax": {
                    "url" : "/post_submit.cfm",
                    "type" : "POST",
                    "data": function (d) {
                        return $.extend({}, d, {
                            "DateS": $('#DateS').val(),
                            "DateX": $('#DateX').val(),
                            "ticketType":$('#ticketType option:selected').toArray().map(function(item) { return item.value; }).join(),
                            "finalStatus": $("#finalStatus option:selected").toArray().map(function(item) { return item.value; }).join()
                        });
                    }
                },
                "language": {
                        "processing": '<i class="fa fa-spinner fa-spin fa-3x fa-fw"></i><span class="sr-only">Loading...</span> ',
                        "emptyTable": "No Data available"
                },
                "scroller": {
                  loadingIndicator: true
                },
                "initComplete" : function () {
                    $('.dataTables_scrollBody thead tr').addClass('hidden');

                }
            });
        });

When the code goes to post.cfm or post_submit.cfm

Not sure what is going on, what is the best way to track down the error, i am trying everything to atleast show me an error and if it can tell me an error, atleast i can debug but right now, it does even go to that point

please guide

here is the error what i am getting

DataTables warning: table id=datatables - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 14,502Questions: 25Answers: 3,443

    As I mentioned in your other thread the problem is with the web server configuration or other server side error. Posting your client code here won't help troubleshoot the problem. The 302 error is not a Datatables issue. You can test with the curl command. See this POST with curl tutorial for basic steps.

    Have you searched sites like Stack Overflow for help with IIS, Coldfusion and 302 errors? Here is one SO thread that talks about Handler Mappings. Maybe that is what you need.

    Kevin

  • maniyamaniya Posts: 34Questions: 8Answers: 0

    i did everything, but i am not getting a small glimpse of an error

    not sure what is wrong

  • colincolin Posts: 13,187Questions: 0Answers: 2,252

    As Kevin explained, a 302 is a server error, so it would be worth checking on StackOverflow, as it's not a DataTables issue,

    Colin

  • maniyamaniya Posts: 34Questions: 8Answers: 0

    this is strange, the error is happening when datatables ajax is called, not jquery ajax, so it seems the datatables ajax has something which is not working

  • colincolin Posts: 13,187Questions: 0Answers: 2,252

    Can you link to your page so we can take a look, please?

    Colin

  • kthorngrenkthorngren Posts: 14,502Questions: 25Answers: 3,443
    edited December 2021 Answer ✓

    Your jQuery ajax is using "/post.cfm" while Datatables ajax is using "/post_submit.cfm". They are two different URLs so they can't be compared. The configuration in your IIS server for /post_submit.cfm is causing the 302 response.

    Have you tried the curl command I suggested to show its not a Datatables issue?

    Kevin

  • maniyamaniya Posts: 34Questions: 8Answers: 0

    i fixed it, due to security, i was missing the csrf token, passed that and it started displaying

Sign In or Register to comment.