Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8686817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:57:40+00:00 2026-06-12T22:57:40+00:00

I wish to have a webpage that uses AJAX to access a PHP file

  • 0

I wish to have a webpage that uses AJAX to access a PHP file in ./ajax/file.ajax.php

Trouble is, I don’t want people to be able to type the address in their browser to access that PHP file directly.

Is there a way I can make it so that only AJAX requests can access the file?

Is there something I can check for in the PHP file to achieve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T22:57:42+00:00Added an answer on June 12, 2026 at 10:57 pm

    If you’re using jQuery to make the XHR, it will set a custom header X-Requested-With. You can check for that and determine how to serve your response.

    $isXhr = isset($_SERVER["HTTP_X_REQUESTED_WITH"])
             AND strotlower($_SERVER["HTTP_X_REQUESTED_WITH"]) == "xmlhttprequest";
    

    However, this is trivial to spoof. In the past, I’ve used this to decide whether to render a whole page (if not set) or a page fragment (if set, to be injected into current page).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have built a webpage, splashcreen.html , that when someone loads index.php will automatically
I have a generalized media player web app that I wish to be able
I wish to have a page that has a fixed height (without scroll bars).
I have a very simple command line Java application that I wish to port
I have a question... I wish take from a string that contains a name
I have some XML text that I wish to render in an HTML page.
I have data grids on my webpage that need to be refreshed every few
I have a webpage which has games on. I realize that there will be
I have a Silverlight 2 control that I wish to fill the browser. I
Here is i wish to do. I want to have multiple webview loading their

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.