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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:39:27+00:00 2026-06-07T00:39:27+00:00

I am facing a common issue CORS with Prototype Ajax request. I Googled for

  • 0

I am facing a common issue CORS with Prototype Ajax request. I Googled for about 2 hours, and still I am not able to fix the issue. I tried a different approach. Nothing helped me. I need to set orgin, Access-Control-Allow-Origin, etc. in my code. I referred to the following sites, but they were of no help.

http://kourge.net/node/131

Cross Origin Resource Sharing with PrototypeJS

new Ajax.Request("http://localhost:4000/somefolder/some.xml", {
    //new Ajax.Request(source, {
        asynchronous: false,
        method: 'get',
        contentType: 'text/xml',
        //requestHeaders: ('Access-Control-Allow-Origin', '*','Access-Control-Allow-Methods','GET','Access-Control-Max-Age','1000','Access-Control-Allow-Headers','*' ),
        //requestHeaders: (Access-Control-Allow-Origin, *,Access-Control-Allow-Methods,GET,Access-Control-Max-Age,1000,Access-Control-Allow-Headers,*),
        //onCreate: function(request) { 
        //   request.transport.setRequestHeader = Prototype.emptyFunction; 
    // },
    requestHeaders: {Access: '*/*'},
    onSuccess: function(result) {   
        alert(result.responseXML);
    }
}); 

And I’m getting the following response:

Response Headersview source
Connection  keep-alive
Content-Length  0
Content-Type    text/html; charset=utf-8
Date    Thu, 05 Jul 2012 08:58:08 GMT
X-Powered-By    Express
Request Headersview source
Accept  text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding gzip, deflate
Accept-Language en-us,en;q=0.5
Access-Control-Request-He...    x-prototype-version,x-requested-with
Access-Control-Request-Me...    GET
Connection  keep-alive
Host    localhost:4000
Origin  http://localhost:8080
User-Agent  Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20100101 Firefox/14.0

I am sending it as a GET request, but it’s going as an OPTIONS request.


I added the header in response also. Still no help.

app.configure('development', function() {
    app.use(express.errorHandler( {
        dumpExceptions :true,
        showStack :true
    }));
    app.all('*', function(req, res, next) { 
        res.setHeader('Access-Control-Allow-Origin', 'http://localhost:4000, http://localhost:8000');
        res.setHeader('Access-Control-Allow-Methods', 'GET,POST,PUT,DELETE');
        res.setHeader('Access-Control-Allow-Headers', 'x-prototype-version,x-requested-with');
        res.setHeader('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8');
        res.setHeader('Accept-Encoding', 'gzip, deflate');
        res.setHeader('Accept-Language', 'en-us,en;q=0.5');
        res.setHeader("X-Requested-With", "XMLHttpRequest" );
        res.setHeader("Orgin", 'http://localhost:4000'); 
        next()
    });
});

The added/reflected response:

Response Headersview source

Accept  text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding gzip, deflate
Accept-Language en-us,en;q=0.5
Access-Control-Allow-Head...    x-prototype-version,x-requested-with
Access-Control-Allow-Meth...    GET,POST,PUT,DELETE
Access-Control-Allow-Orig...    http://localhost:4000, http://localhost:8000
Allow   GET,POST,PUT,DELETE,TRACE,CONNECT,PROPFIND,PROPPATCH,MKCOL,COPY,MOVE,LOCK,UNLOCK,VERSION-CONTROL,REPORT,CHECKOUT,CHECKIN,UNCHECKOUT,MKWORKSPACE,UPDATE,LABEL,MERGE,BASELINE-CONTROL,MKACTIVITY,ORDERPATCH,ACL,SEARCH,PATCH,PURGE
Connection  keep-alive
Content-Length  224
Content-Type    text/html; charset=utf-8
Date    Fri, 06 Jul 2012 06:20:51 GMT
Orgin   http://localhost:4000
X-Powered-By    Express
X-Requested-With    XMLHttpRequest

Request Headersview source

Accept  text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding gzip, deflate
Accept-Language en-us,en;q=0.5
Access-Control-Request-He...    x-prototype-version,x-requested-with
Access-Control-Request-Me...    GET
Connection  keep-alive
Host    localhost:4000
Origin  http://localhost:8080
User-Agent  Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20100101 Firefox/14.0

What else can I do to fix this issue?

  • 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-07T00:39:29+00:00Added an answer on June 7, 2026 at 12:39 am

    Access-Control-Allow-Origin: * needs to be part of the response header, not the request header (your Ajax request).

    The server your requesting the data from is what grants/denies permission from cross-domain scripts.

    I’d look into how to set Access-Control-Allow-Origin for whatever server environment you’re using.

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

Sidebar

Related Questions

Cross-site request forgery is common on web now a days. I am facing this
Facing some issue in Talend Admin Console, the jobs that are running from IDE
Facing a problem, it seems my data stored in SQL Server does not stored
issue facing while loading the messages in to mq channel, recieving an error like
I'm now facing the most common problem faced my many while working with listboxes.
This is a common task I'm facing: splitting a space separated list into a
I am facing a class resolution issue while trying to make my architecture flexible.
I am facing strange issue with our WCF service. The same code was working
Question 1: (Solved) I'm facing an issue with class loader in Weblogic. I've a
I'm building a MEF-based plugin-centric WPF application and I'm facing an issue with GetExports,

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.