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 8755787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:55:28+00:00 2026-06-13T13:55:28+00:00

Create a web service on http://www.a.com/service.asmx and send a cross-domain ajax request to it

  • 0

Create a web service on http://www.a.com/service.asmx and send a cross-domain ajax request to it from http://www.b.com. Check the headers in Firebug, or in Live HTTP Headers, or any other plugin you wish.

There is no trace of the X-Requested-With HTTP Header field among request headers.

However, if you send an ajax request to the same service from the same domain (say for example http://www.a.com/about), you will see that header field.

Why is the X-Requested-With header field omitted for cross-domain ajax requests?

Update: I know that JSONP calls are not AJAX calls in nature. Thus you won’t see any X-Requested-With header field, in JSONP calls.

  • 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-13T13:55:29+00:00Added an answer on June 13, 2026 at 1:55 pm

    If you are using jQuery to do your ajax request, it will not send the header X-Requested-With (HTTP_X_REQUESTED_WITH) = XMLHttpRequest, because it is cross domain. But there are 2 ways to fix this and send the header:

    Option 1) Manually set the header in the ajax call:

    $.ajax({
         url: "http://your-url...",
     headers: {'X-Requested-With': 'XMLHttpRequest'}
    });  
    

    Option 2) Tell jQuery not to use cross domain defaults, so it will keep the X-Requested-With header in the ajax request:

    $.ajax({
      url: "http://your-url...",
     crossDomain: false
    });
    

    But with this, the server must allow those headers, then the server needs to print those headers:

    print "Access-Control-Allow-Origin: *\n";
    print "Access-Control-Allow-Headers: X-Requested-With, Content-Type\n";
    

    The first line above will avoid the error “Origin is not allowed by Access-Control-Allow-Origin.”
    The second line will avoid the error “Request header field X-Requested-With is not allowed by Access-Control-Allow-Headers.”

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

Sidebar

Related Questions

Im trying to create a web service which gets to a URL e.g. www.domain.co.uk/prices.csv
I'm trying to create a http request to our web service, my test XML
I was looking for a way to route http://www.example.com/WebService.asmx to http://www.example.com/service/ using only the
I'm following this tutorial for the login and registration http://www.raywenderlich.com/13511/how-to-create-an-app-like-instagram-with-a-web-service-backend-part-12 . When I click
I want to create a web service in ASP.NET that fetches data from a
I instantiate the HttpWebRequest object: HttpWebRequest httpWebRequest = WebRequest.Create(http://game.stop.com/webservice/services/gameup) as HttpWebRequest; When I post
I am new to java based web service. I am able to create web
I need to create a web service that returns XML data to some of
Objective: I want to create a web service that allows me to connect to
I am needing to create a web service, so the first thing I did

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.