Unable to add additional columns due to ajax error
Unable to add additional columns due to ajax error
nikve
Posts: 19Questions: 2Answers: 0
Hello!
At the moment I'm attempting to add another column to my page. However, I will get an ajax error whenever I do. It's fine with 10 columns, but as soon as I add the 11th, the ajax error will appear.
Here's my debugger
http://debug.datatables.net/ewolon
And the console error shows:
responded with a status of 403 (Forbidden)
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
403 forbidden is a response from the server. Not sure what your backend is but I would start by checking permissions of the script and looking at server logs.
Kevin
I'm doing shared hosting and all of the permissions for files and folders for this site are set correctly.
Looking at the error log in cpanel nothing seems to show up. Error logs locally in the directory are also unhelpful, as it's not recording any.
Again, I'm not...really sure why it's fine with 10 columns and not the 11th. It doesn't draw from any other script, so I can't imagine what would be throwing out the 403.
It will still pull all the data for all 11 columns, but the formatting is broken (and pulls up 900 rows, vs the default display set of 25) and the ajax error pops up
Still unable to fix this on my own after many hours. Is there any data I can show that would help in resolving?
Allan may have suggestions on data to look at but I have a couple questions.
Have you looked at the specific rows (900 that is displayed and 901 which is the first not displayed) where the error is occurring? Not knowing the specifics of your backend I would suspect corrupt data from the DB to the server_processing.php script or maybe special characters that the script is unable to process.
Maybe you can filter out row 901 (or the one not being displayed) from the response to see if the remaining rows are return and the table is displayed properly.
Looks like you are at DataTables 1.10.9 which is a few revisions behind. I haven't used the DT PHP scripts but something may have been fixed. Current;y DT is at 1.10.13. Allan may be able to comment on whether any of the resolved issues might affect you.
It may help to post the data from the new column from the first row not displayed.
Kevin
Thank you for your response!
The rows seem to all display okay at 10 columns. I have it set to be able to show 10, 25, 50, or 100 rows at a time and haven't had any problems. However, just to be sure, I loaded up a test SQL database that has a single row of data, plugged that info in and was still getting the same error. Fine at 10 columns, crash at 11.
If 1.10.13 fixes it, that would be great, though.
That's good info. Please post a copy of the data that causes the problem.
Is the 11th column always the same column or have you tried different combinations of 10 columns? Just trying to narrow down if the problem is with one particular column.
Kevin
Just to check my understanding - the only thing you are changing is that you are going from 10 columns to 11? The script that you are calling works without issue with 10 columns, but as soon as you add another (and don't change the URL) you get the 403 error?
If so, then you are very likely encountering a limit on the query string length that the HTTP server will accept. If you are in a shared hosting environment you aren't going to be able to change that easily I would suspect.
So the way to workaround this is to POST the parameters rather than sending them as GET. Since you are using the legacy parameters you can use the sServerMethod option to do that (
ajax
is the way with the newer style).Then all you need to do is update your server-side script to use POST parameters rather than GET, and that should be it.
Allan
Yes, you have it correct.
So just to make sure I have this correct, I would go:
// DataTable
var table = $('#table_id').DataTable(
{
"bServerSide": true,
"sAjaxSource": "/server_processing.php",
"sServerMethod": "POST",
"bProcessing": true,
"iDisplayLength": 25,
order: [[ 0, 'asc' ]],
});
And then go into server_processing.php I would change $_GET to $_POST? I'm assuming that would only be during the Paging and Ordering section of the script?
Yes, that looks correct.
Allan
Hm. I'm still getting an error after that, but now it's saying that server_processing is forbidden 403.
Failed to load resource: the server responded with a status of 403 (Forbidden)
So I have no idea what I'm doing wrong
Without being able to see it, I don't know either .
Does server_processing have the correct permissions set on it?
Allan
It does, yes.
Here's the index.php and server_processing.php in a pastebin if that helps.
https://www.pastiebin.com/58a3f5e64065f
https://www.pastiebin.com/58a3f770cef7a
Unfortunately not really since it isn't a PHP issue, but rather one with the HTTP server or the file system.
What does your server's error log say?
Allan
My server error log is showing nothing, nor is the error_log in the folder.
What server are you using?
I'm using a shared host through acenet.
Presumably Apache, which I think is what tangerine was asking?
There should be at least something shown if its a 403 response. Perhaps the access log would show something.
Allan
Yep.
@nikve: there must be something relevant in the logs.
If there were, it'd make it a lot easier. there's nothing in the error logs for that domain. I have a couple from bots trying to get to my other hosted sites (Trying to find files that don't exist), but literally nothing for that one. There's no errors being generated in error_log either. There were some from older errors that I've fixed, but since those were fixed none have generated.
rpwith.us/OwnersTest/Manage/ is the site that I'm doing tests with before it goes live
And it's probably apache, yes.
Here's the log:
Thank you for the link. I can see that if I try to get it via the browser, then actually it works no problem. However, the POST that is being made fails with the 403.
Experimenting with it in cURL shows that your server is rejecting this following in the POST data:
I have no idea why that would be. I've not encountered that before. Two things to try:
ajax
rather than sAjaxSource .Allan
Since I cannot update apache or php (Shared server) I've tried the new server side processing and I changed to the ajax Option and the error went away! However, now it won't limit the lines called and I can no longer use the drop down to change how many rows are shown. Like, it breaks the formatting and decides to spit out the entire table.
I thought it was the error that was breaking the formatting with the 11th column but apparently not. With 10 columns, it displays with no issue.
Example:
http://rpwith.us/OwnersTest/
vs
http://rpwith.us/OwnersTest/Manage/
I suppose I'll have to try and update to the new version and see if that fixes it. Would the old css files work with the new datatables so I don't have to redo that?
There are numerous errors in your HTML. DataTables efficacy depends on having at least a valid HTML table.
I've got it working now Thank you everyone!