Inside my api folder is the server.php file and the ssp.class.php file. Inside my js folder is the datatables.js file and other js files that the template requires. When you mention that I’m telling it to go one folder up into a folder called api to find server.php, it should be going back to the root folder (ccrp) then into api, followed by server.php. I think it is, but for some reason, it isn’t pulling in the data.
And try and tell me if you succeeded.
Browser pulls datatables.js out from js folder and sets it as it is in the root, so after that it is easy and that is why you have to remove the two dots.
That didn’t work. It wouldn’t work anyway because that file is not in the root folder, it is in the js folder. By removing the two dots, you’re telling the js file to look into a folder called api in the current directory and look for a file called server.php and both of them do not exist in the js directory. That’s why you need the two dots in there because you’re telling the js file to go back one folder, then look for the api folder where the server.php file is. The problem is that it says “No data available in the table.”
No it doesn’t, otherwise I wouldn’t have said that. I just tried this moments ago.
Yes, it is a problem and my table is not empty. This has been verified by various people in this post. I even posted a screenshot in this post that shows the data being called by the PHP file, but I had to remove it because it is personal data that I cannot show to the public. @droopsnoot can even vouch for this:
Indeed, I saw a screen shot showing data when the PHP code was executed directly. So either the PHP is not being executed, or the results are not being passed in to the table correctly.
But, have you tried writing a bit of text to a file using file_put_contents() as part of your PHP, just to see if the file gets created? If it does, you know your PHP is being run. If not, it isn’t.
I went back and double checked my js file to make sure it was loading correctly. When I checked the code in my browser to see what it was calling, it looked like this:
.. means “go up a folder.”
You are at /ccrp/
Your script is telling it to contact /api/server.php.
Your file is at /ccrp/api/server.php.
It 404’s because you’re telling it to find the file in the wrong place.
Remove the ../ from the beginning of the ajax directive.
This is false. My table was never empty to begin with as I previously stated. When I tried what you suggested, it didn’t work at first because the code had never refreshed and I did not know this. When I loaded the js file directly and refreshed the page, the code refreshed to the code I had typed and provided the error. It was only then that I followed yours and @m_hutley’s guidance to solve the problem.
So yes, you partially provided the answer. And for that, I apologize.
I came upon your problem, I think it will help you to understand better if you go to this site https://www.datatables.net/ there should be an equivalent way to do this in PHP; it just a web page isn’t it and jQuery works in conjunction with the DOM no mater which website, at least that’s jQuery’s raison d’etre (reason for being).
Mel