Hack Forums
[Help] AJAX (HTTP_X_REQUESTED_WITH) not working on apache2 (debian) - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Coders Lounge (https://hackforums.net/forumdisplay.php?fid=5)
+---- Thread: [Help] AJAX (HTTP_X_REQUESTED_WITH) not working on apache2 (debian) (/showthread.php?tid=5661730)



AJAX (HTTP_X_REQUESTED_WITH) not working on apache2 (debian) - Exeption™ - Jul 4, 2017

Hey HF ✌

Im trying to get this code working to load sub pages, but since i changed my server to linux, its not working anymore.

Code:

PHP Code

<?php
if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
{
    if(!isset(
$_GET['page'])){
        include(
'pages/index.php');
    }else{

        switch(
$_GET['page']){

            case 
'index':
                include(
'pages/index.php');
                break;
            case 
'settings':
                include(
'pages/settings.php');
                break;
            case 
'profile':
                include(
'pages/profile.php');
                break;
            case 
'terms':
                include(
'pages/terms.php');
                break;
            case 
'history':
                include(
'pages/connections.php');
                break;
            default:
                include(
'pages/index.php');
        }
    }
    exit;
}
?>

Greetings.


* - TCP - Jul 4, 2017

Did you install PHP correctly(try to run phpinfo())? Do you have any logs in apache(/var/log/apache2/error.log)? Did you set proper rights to folder/files?


* - SIM-2223238 - Jul 4, 2017

What's the actual error? What do you mean its not working anymore.


* - Exeption™ - Jul 4, 2017

(Jul 4, 2017 07:08 AM)KitKat707 Wrote:  Did you install PHP correctly(try to run phpinfo())? Do you have any logs in apache(/var/log/apache2/error.log)? Did you set proper rights to folder/files?
Yes, seems fine.
[Image: fac5ebd239.png]

"Did you set proper rights to folder/files?"

I pointed my domain to the folder with the web files.

But..not more.


* - TCP - Jul 4, 2017

(Jul 4, 2017 07:16 AM)Exeption™ Wrote:  "Did you set proper rights to folder/files?"

I pointed my domain to the folder with the web files.

But..not more.

That's not what I meant, I mean the permissions of the files, you are able to see the phpinfo page from the domain?

Try also using $_SERVER['DOCUMENT_ROOT']."/pages/page.php" in include


* - Exeption™ - Jul 4, 2017

"you are able to see the phpinfo page from the domain?"

Yes, it is.

"Try also using $_SERVER['DOCUMENT_ROOT']."/pages/page.php" in include"
EDIT:
Not working too. ^^


* - TCP - Jul 4, 2017

(Jul 4, 2017 07:39 AM)Exeption™ Wrote:  Not working too. ^^

Can you show me your current code? Also add error_reporting(E_ALL) and tell me about the apache logs


* - Exeption™ - Jul 4, 2017

(Jul 4, 2017 07:54 AM)KitKat707 Wrote:  Can you show me your current code? Also add error_reporting(E_ALL) and tell me about the apache logs

Thanks for your help mate.

Im switching now back to a Windows server 🤝

the apache logs did showed that the file could not found on the server.
(domain.com/index as example)

Have a nice day,

Im quitting linux again lol. -.-