Datatables warning: table id =datatable - Ajax error (URL Not Found)

Datatables warning: table id =datatable - Ajax error (URL Not Found)

shomimshomim Posts: 3Questions: 1Answers: 0

Good day, how's life velaz,
Okey, I had a problem for the DataTable, when I put them running in my local, its run perfectly. But when I publish it and access a database, it appear such error :

...Datatables warning: table id =datatable - Ajax error. For more information about this error, please see http://datatables.net/tn/7...

Look for the browser console, bring this error : POST http://localhost/Draft/getDraft 404 (Not Found)

~ This is my .js code :
rootUrl = '@Url.Content("~")';
table = $("#tableDraft").DataTable(
{
//// destroy: true,
"processing": true, // for show progress bar
"serverSide": false,
"filter": true, // this is for disable filter (search box)
"orderMulti": false, // for disable multiple column at once
"ajax": {
"url": '" + Url.Content("~/Controllers/DraftController/getDraft") + "',
"type": "POST",
"datatype": "json"
},

~ This function getDraft in the controller :
var data = (from c in db.Drafts where c.checkOut == true orderby c.Date descending select
c).Take(200).ToList();
return Json (new { data = data }, JsonRequestBehavior.AllowGet);

~ I've been replace url ajax with this option :
a. "/Draft/getDraft" and
b. '@Url.Action("getDraft", "Draft")'
... but seems no option to resolve this

~ Also I've insert :
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
... in the web.config, nothing changed.

Any idea???

Thanks,
Regards

Answers

  • allanallan Posts: 63,258Questions: 1Answers: 10,421 Site admin

    Look for the browser console, bring this error : POST http://localhost/Draft/getDraft 404 (Not Found)

    That seems fairly clear to me - the server isn't accepting requests to that URL. You need to edit add a suitable route or update the URL to one the server does expect.

    If you need help configuring a .NET server you'll probably need to ask on the MSDN forums rather than here - I'm not IIS expert!

    Allan

  • shomimshomim Posts: 3Questions: 1Answers: 0

    Thanks for your reply, Allan,

    Is my url request concerned basicly wrong or what? Coz I've been replace it with several URL syntax.
    I mean, why its totally work before publish neither after

    Regards

  • allanallan Posts: 63,258Questions: 1Answers: 10,421 Site admin

    The URL itself is fine - but as the error clearly states, the server isn't finding anything that that URL to respond with. Now that's either a routing issue, a controller name issue or the URL being requested is wrong.

    As I say, if you need help with .NET routing, you'd be best asking on MSDN since that is not my area of expertise.

    Allan

This discussion has been closed.