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

  • Home
  • SEARCH
  • 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 341301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:41:48+00:00 2026-05-12T10:41:48+00:00

I have a template set up that I’m making ajax calls to via jQuery.

  • 0

I have a template set up that I’m making ajax calls to via jQuery. I’m passing a URL parameter called “method” and then doing a <cfswitch> through each method to determine what block of code to execute.

Problem is, I don’t want this page to be accessible outside of the ajax call. In other words, I don’t want the template to run if someone just types the URL into their browser.

Is there a way to do that? I thought in .php there was a way to tell what type of request it was. Does anything like this exist in Coldfusion? Or any suggestions?

  • 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-05-12T10:41:48+00:00Added an answer on May 12, 2026 at 10:41 am

    jQuery injects the request with a X-Requested-With header set with the value “XMLHttpRequest”. In coldfusion, you can view this by dumping the HTTP Request:

    <cfdump var="#getHTTPRequestData()#">
    

    So, all you need to do is test for that header, for example:

    <cfset reqData = getHTTPRequestData()>
    <cfif structKeyExists(reqData.headers,"X-Requested-With") and reqData.headers["X-Requested-With"] eq "XMLHttpRequest">
        Got an ajax request
    <cfelse>
        <!--- do something else, or nothing --->
    </cfif>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a template method that is designed to work with a specific set
I have an array set inside a velocity template that contains some paths. The
I have a smarty template that has a variable set that is a custom
i have template base.html and some children templates. I don't know how to set
We have a multi-store set up and I wanted to change the template slightly
If I have a function overload set similar to template<typename T> void f(T&& t,
I have template that looks like this: 100 template<size_t A0, size_t A1, size_t A2,
I have the listBox and a ObservableCollection. The listBox.ItemSource (listNotify.ItemSource) is set to that
I have a tab content template set to my tab control: <TabControl SelectedIndex=0 ItemsSource={Binding
I have a multi-page template set up. The first page has a set of

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.