Datatable worked normally in my localhost but when i published it doesn't work ?

Datatable worked normally in my localhost but when i published it doesn't work ?

emna_temna_t Posts: 3Questions: 1Answers: 0
edited March 2018 in Free community support

Datatable worked normally in my localhost but When I publish my site , an error appears " Ajax Error: tn/7"
when I open my console , the error is: 404 - Not Found.
The URL requested was not found on the server.
Any Help please?

Answers

  • emna_temna_t Posts: 3Questions: 1Answers: 0

     $(document).ready(function () {
            datatable =
            $("#TelTable").DataTable({
                "paging": false,
                "ordering": false,
                "info": false,
                "searching": false,
                "serverSide": true,
                "ajax": {
                    "url": "/formulaire/GetData",
                    "type": "POST",
                    "datatype": "json",
    
    
                },
                "columns": [
                    {
                        "data": "Libelle",
                        "width": "100px"
                    },
                    {
                        "data": "NumTel",
                        "width": "100px"
                    },
                      {
                          "data": "Id", "render": function myfunction(data) {
    
                              return "<a class='btn btn-default btn-sm' onclick=PopupForm('@Url.Action("AjoutOuModif","formulaire")/" + data + "')><i class='fa fa-pencil'> </i>  @GlobalRes.Modifier</a> <a class='btn btn-danger btn-sm' style:'margin-left:30px' onclick=Supprimer('@Url.Action("Supprimer","formulaire")/" + data + "')> <i class='fa fa-trash'> </i> @GlobalRes.Supprimer</a>";
    
                          },
                          "orderable": false,
                          "width": "75px",
                          "searchable": false
    
                      }
                ],
                "language": {
                    "emptyTable": "click here to add a phone number"
                }
            })
        } );
    

    ////////////

    this method is to get data and put it ih the columns in the datatable
    [HttpPost]
    public ActionResult GetData()
    {
    List<CandidatViewModel> LstF = new List<CandidatViewModel>();
    using (db)
    {

                List<Tel> telslST = db.Tel.Where(x => x.CandidatID == EnregistrerController.identifiant).ToList();
    
                Tel[] TabTemp = telslST.ToArray();
    
                for (int i = 0; i < TabTemp.Length; i++)
                {
                 T_INT_LISTE_TEL typetel = db.T_INT_LISTE_TEL.Find(TabTemp[i].TypeTelID);
                   CandidatViewModel telephone = new CandidatViewModel();
                   telephone.Libelle = typetel.Libelle;
                    telephone.NumTel = TabTemp[i].NumTel;
                    telephone.Id = TabTemp[i].TelID;
                    telephone.CANDIDATID = TabTemp[i].CandidatID;
                    LstF.Add(telephone);
    
    
                }
    
                return Json(new { data = LstF }, JsonRequestBehavior.AllowGet);
            }
        }
    
    ty.PNG 55.9K
  • kthorngrenkthorngren Posts: 21,059Questions: 26Answers: 4,903

    This error is coming from your server. Start by looking at the server logs to see why its returning 404.

    Kevin

  • emna_temna_t Posts: 3Questions: 1Answers: 0
    edited March 2018

    i checked my server logs but it doesn't show me anything that may be the problem causing this error with charging datatables
    please i need your help as sooon as possible and thanks

  • colincolin Posts: 15,235Questions: 1Answers: 2,597

    Hi emna_t,

    The screenshot in the original post shows two URLs that are failing, GetData and GetDataEmail. They must be on your localhost server, but weren't transferred to your live server. I'd compare the directory trees on both servers as a starting point.

    Hope that helps,

    Colin

This discussion has been closed.