Datatable error - First 400 bad request - Then 403
Datatable error - First 400 bad request - Then 403
I had a 400 bad request with the get request
table = $('#mytable').DataTable({
"bJQueryUI": true,
"scrollX": true,
"bProcessing": true,
"bServerSide": true,
"bInfo":true,
"bFilter": false,
"sAjaxSource" : "getdetails",
//"sServerMethod": "POST",
// "fnServerParams": function ( aoData ) {
// aoData.push( JSON.stringify({ "name": "tempsId", "value": $('#tempId').val() } ));
// },
"fnServerData": function ( sSource, aoData, fnCallback ) {
aoData.push( { "name": "tempsId", "value": $('#tempId').val() } );
// aoData.push( { "name": "data2", "value": $("#data2").val() } );
$.getJSON( sSource, aoData, function (json) {
fnCallback(json);
} );
},
Then i changed this to regular POST ..
$(function() {
/* var tempId = $('#tempId').val();
alert("tempId"+tempId); */
//csrfToken
var csrfHeader = $("meta[name='_csrf_header']").attr("content");
var csrfToken = $("meta[name='_csrf']").attr("content");
//jqXHR.setRequestHeader('CSRFToken', csrfToken);
// alert('First'+$('#tempId').val());
var StempId= $("#tempId").val();
alert('Second'+StempId);
table = $('#mytable').dataTable( {
"ajax": {
"url": "AllclaimDetails",
"type":"POST",
"data": function ( d ) {
d.tempsId = StempId;
// d.custom = $('#myInput').val();
// etc
},
// "tempsId": $("#tempId").val()
//},
"columns": [
{ "data": "Col1" },
{ "data": "Col2" },
{ "data": "Col3" },
{ "data": "Col4" },
{ "data": "Org_Col1" },
{ "data": "Col6" },
{ "data": "Col7" }
],
xhr: function(){
alert('Third'+$('#tempId').val());
//Get XmlHttpRequest object
var xhr = $.ajaxSettings.xhr() ;
//Set onprogress event handler
//xhr.upload.onprogress = function(event){
//if($('#file').val()!=''){
// var perc = Math.round((event.loaded / event.total) * 100);
// $('#progressBar').text(perc + '%');
// $('#progressBar').css('width',perc + '%');
// //}
};
return xhr ;
},
beforeSend: function( xhr ) {
//Reset alert message and progress bar
xhr.setRequestHeader(csrfHeader, csrfToken);
$('#alertMsg').text('');
$('#progressBar').text('');
$('#progressBar').css('width','0%');
}
}
} );
//alert(table.length);
});
Started getting 403 Error .
But both these error doesnt happen always .. intermittently not sure whats causing this ..
error 400 was really a bad request because Odata was sending everything over i guess ...
Otherone the request size is small but 403 ...
Answers
First place to look would be the server's error logs.
Its not something we can really help with on the client-side that.
Allan