Problems with url ajax

Problems with url ajax

lucianocorteslucianocortes Posts: 7Questions: 1Answers: 0

Hi, I'm new with the new version of datatable 1.10.+

I have this code of a datatable script:

$('#table_results').dataTable({
'bJQueryUI': true,
'sDom': '<"toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix"pf>rt<"F"ip>',
'bRetrieve': true,
'bAutoWidth': false,
'bProcessing': true,
'bServerSide': true,
"bScrollCollapse": false,
"iDisplayLength": iDisplayLength,
"bLengthChange": false,
"sPaginationType": "two_button",
'sAjaxSource': "Principal.aspx/ObtenerRegistros",
"aoColumnDefs": [{
"bSortable": false,
"aTargets": [0]
}],
"aaSorting": [[1, "asc"]],
"fnServerData": function (sSource, aoData, fnCallback) {
aoData.push({ "name": "stRefrescarBoset", "value": $("#stRefrescarBoset").val() });
aoData.push({ "name": "LISTA_CAMPOS_BUSQUEDA", "value": $("#LISTA_CAMPOS_BUSQUEDA").val() });
aoData.push({ "name": "LISTA_VALORES_BUSQUEDA", "value": $("#LISTA_VALORES_BUSQUEDA").val() });
aoData.push({ "name": "LISTA_OPERADORES", "value": $("#LISTA_OPERADORES").val() });
aoData.push({ "name": "LISTA_TIPO_DATOS", "value": $("#LISTA_TIPO_DATOS").val() });
aoData.push({ "name": "LISTA_CAMPOS_SELECT", "value": $("#LISTA_CAMPOS_SELECT").val() });
aoData.push({ "name": "LISTA_CAMPOS_FORMATOS", "value": $("#LISTA_CAMPOS_FORMATOS").val() });
aoData.push({ "name": "LISTA_CAMPOS_LARGOS", "value": $("#LISTA_CAMPOS_LARGOS").val() });
aoData.push({ "name": "LISTA_CAMPOS_ALINEACION", "value": $("#LISTA_CAMPOS_ALINEACION").val() });
aoData.push({ "name": "iLinkColum", "value": $("#iLinkColum").val() });
aoData.push({ "name": "bOnlySelectedIds", "value": $("#chkOnlySelectedIds").is(':checked') });
aoData.push({ "name": "stPreFilter", "value": $("#stPreFilter").val() });
$.ajax({
"dataType": 'json',
"contentType": "application/json; charset=utf-8",
"type": "POST",
"url": sSource,
"data": aoData,
"async": true,
"timeout": 20000, // AGS 14-03-2013 20 segundos de tiempo. Si no, error.
"success": function (responseJson) {
var response = JSON.parse(responseJson["d"]);
}
});
});

Now I'm trying to convert to the new version and I've made this:

$('#table_results').DataTable({
"jQueryUI": true,
"dom": '<"toolbar ui- widget - header ui-corner - tl ui-corner - tr ui-helper - clearfix"p>rt<"F"ip>',
"retrieve": true,
"processing": "Prosesando...",
"serverSide": true,
"pageLength": 10,
"lengthChange": false,
"pagingType": "simple",
"ajax": {
url: 'principal.aspx/ObtenerRegistros',
"contentType": "application/json; charset=utf-8",
"type": "POST",
"dataType": "json",
"dataSrc": '',
"data": function (d) {
return $.extend({}, d, {
"stRefrescarBoset": $("#stRefrescarBoset").val(),
"LISTA_CAMPOS_BUSQUEDA": $("#LISTA_CAMPOS_BUSQUEDA").val(),
"LISTA_VALORES_BUSQUEDA": $("#LISTA_VALORES_BUSQUEDA").val(),
"LISTA_OPERADORES": $("#LISTA_OPERADORES").val(),
"LISTA_TIPO_DATOS": $("#LISTA_TIPO_DATOS").val(),
"LISTA_CAMPOS_SELECT": $("#LISTA_CAMPOS_SELECT").val(),
"LISTA_CAMPOS_FORMATOS": $("#LISTA_CAMPOS_FORMATOS").val(),
"LISTA_CAMPOS_LARGOS": $("#LISTA_CAMPOS_LARGOS").val(),
"LISTA_CAMPOS_ALINEACION": $("#LISTA_CAMPOS_ALINEACION").val(),
"iLinkColum": $("#iLinkColum").val(),
"bOnlySelectedIds": $("#chkOnlySelectedIds").is(':checked'),
"stPreFilter": $("#stPreFilter").val()
});
},
},
"columns": [
{ "data": "COD_FAMILIA" },
{ "data": "NOMBRE_FAMILIA" }
],
"scrollY": true,
"scrollX": true,
"columnDefs": [{
"targets": 0,
"searchable": true
}],
"order": [[1, "asc"]],
"ordering": false,
"success": function (responseJson) {
var response = JSON.parse(responseJson["d"]);
}
});

This give me an error... I have problems with the url... it doesn't work and I'm trying with all url posibilities and always said the same in the chrome console:

jquery.min.js:2 POST http://localhost/DocentemasBts/AplicacionesBO/Familias/principal.aspx/ObtenerRegistros 404 (Not Found)

Please Help... I don't understand my problem :(

Replies

  • kthorngrenkthorngren Posts: 21,351Questions: 26Answers: 4,955

    Might be case sensitive. In your original you have:

    'sAjaxSource': "Principal.aspx/ObtenerRegistros",

    But in your new code you have:

    url: 'principal.aspx/ObtenerRegistros',

    If changing principal to Principal doesn't help then you will need to start by looking at your server logs to see why it's returning the 404 error.

    Kevin

  • lucianocorteslucianocortes Posts: 7Questions: 1Answers: 0

    kthorngren, i tried both... with Principal and principal... and many path but the error doesn't disappear :(

This discussion has been closed.