continues Error 404

continues Error 404

rangaranga Posts: 31Questions: 12Answers: 2
edited September 2018 in General

I have this nested table code. but within detail part click im keep getting error 404. but the link is fine even i pasted on address bar it works and return pure data.

what else could be the problem ? could data mismatches cause this error too ? any idea would be a big help .

`
<table id="example" class="display nowrap" cellspacing="0" width="100%">
<thead>
<tr>
<th></th>
<th>Item 1</th>
<th>Item 2</th>
<th>Item 3</th>
<th>Item 4</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr data-child-value="hidden 1">

                        <td class="details-control">Click Here to Run Ajax</td>
                        <td>
                            @Html.DisplayFor(modelItem => item.IOU_ID)
                        </td>
                        <th>
                            @Html.DisplayFor(model => item.POPM_IOU_TOPIC)
                        </th>
                        <td>
                            @Html.DisplayFor(modelItem => item.POPM_IOU_Client)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.POPM_IOU_DOC_NO)
                        </td>
                    </tr>
                }
            </tbody>

        </table>


         <script type="text/javascript">
                    var dd; // to pass header row data to detail table
                    function format(name, value) {
                        return '<div id="addToMe" ><table id="example1" cellspacing="0" width="90%">' +
                           ' <thead>' +
                            '<tr>' +
                            '<th></th>' +
                           '<th>CI 1</th>' +
                            '<th>CI 2</th>' +
                             '</tr>' +
                           '</thead>';
                    }
                    $(document).ready(function () {
                        var table = $('#example').DataTable({});
                        // Add event listener for opening and closing details
                        $('#example').on('click', 'td.details-control', function () {
                            var tr = $(this).closest('tr');
                            var row = table.row(tr);

                            if (row.child.isShown()) {
                                // This row is already open - close it
                                row.child.hide();
                                tr.removeClass('shown');
                            } else {
                                row.child(format(tr.data('child-value'))).show();
                                tr.addClass('shown');
                            }
                            dd = table.cell(this, 1).data();  // asign header id to variable
                            alert(table.cell(this, 1).data());
                            var table1 = $('#example1').DataTable({
                                "processing": true,

                                "bProcessing": false,
                                "ajax": {


                                  //  "url": '@Url.RouteUrl(new{ action="IocollectionPickup", controller= "PO_Trn_IOU" })'
                                    "url": "PO_Trn_IOU/IoUcollectionPickup",

                                    "type": "GET",
                        "data": { "theData": dd },
                                    "contentType": "application/json; charset=utf-8",
                                    //!adding the brackets and title matching c# action
                                    // assign header row id to get detail data
                                    "dataType": "json",
                                    "asynch": false,
                                    "success": function (theData) {
                                        var tbody = $('#example1 tbody')

                                        $.each(theData, function (index, value) {
                                            var row = $("<tr>");
                                            row.append($("<td>").text(value.date));
                                            row.append($("<td>").text(value.docno));
                                            tbody.append(row);
                                        });
                                        alert("done");
                                    }
                                },
                            });
                        });
                    });

            </script>
        `

Controller

I put some sample data to check the route. but still 404.
'
public JsonResult IoUcollectionPickup(string theData )
{

        POPM_TRN_IOUColection pop = new POPM_TRN_IOUColection();

        List<POPM_TRN_IOUColection> iocollection = new List<POPM_TRN_IOUColection>();
        POPM_TRN_IOUColection item1 = new POPM_TRN_IOUColection { date = Convert.ToDateTime("3/5/68"), Collection_DocNumber = "doc1" };
        POPM_TRN_IOUColection item2 = new POPM_TRN_IOUColection { date = Convert.ToDateTime("3/5/69"), Collection_DocNumber = "doc2" };
        iocollection.Add(item1);
        iocollection.Add(item2);

        return Json(iocollection, JsonRequestBehavior.AllowGet);


    }'

Answers

  • kthorngrenkthorngren Posts: 21,327Questions: 26Answers: 4,949

    The server is returning the 404 Not Found error. The place to start is to look a the server logs to see why its returning the 404.

    Kevin

  • rangaranga Posts: 31Questions: 12Answers: 2

    Issue here was when working with Mvc when passing multiple parameters through Ajax controller expect data as model data. But could solved by add parameters to array and use Json stringfy before assign to data. It has nothing to do with 404. Sorry I solved this earlier but forgot to put the solution . Could help someone else.

This discussion has been closed.