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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:38:41+00:00 2026-06-08T04:38:41+00:00

I try to make Cross Domain POST requests and get back JSON encoded responses,

  • 0

I try to make Cross Domain POST requests and get back JSON encoded responses,

everything works fine except in IE 7, 8, 9.
I have try those solutions but i get this error:

Object doesn’t support property or method ‘setRequestHeader’

Function createXMLHTTPObject() – attempt 1

function createXMLHTTPObject() {
    var xmlhttp = false;
        var is_IE = window.XDomainRequest ? true : false;
        if (is_IE) {
            xmlhttp = new window.XDomainRequest();
        } else {
            if (window.XMLHttpRequest) {
                xmlhttp = new XMLHttpRequest();
            } else {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
        }
    return xmlhttp;
}

Function createXMLHTTPObject() – attempt 2

var XMLHttpFactories = [
    function() { return new XMLHttpRequest() },
    function() { return new ActiveXObject("Msxml2.XMLHTTP") },
    function() { return new ActiveXObject("Msxml3.XMLHTTP") },
    function() { return new ActiveXObject("Microsoft.XMLHTTP") }
];

function createXMLHTTPObject() {
    var xmlhttp = false;
    for (var i=0; i<XMLHttpFactories.length; i++) {
        try {
            xmlhttp = XMLHttpFactories[i]();
        }
        catch(e) {
            continue;
        }
        break;
    }
    return xmlhttp; 
}

Function send()
Here it returns the error, at: req.setRequestHeader('User-Agent', 'XMLHTTP/1.0');

function send(postData, callback) {
    var url = 'http://domain.com/ajax-processing.php'; //url overlap
    var req = createXMLHTTPObject();
    if (!req) return;
    var method = (postData) ? "POST" : "GET";
    req.open(method, url, true);
    req.setRequestHeader('User-Agent', 'XMLHTTP/1.0');
    if (postData) {
        req.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
    }
    req.onreadystatechange = function() {
        if (req.readyState != 4) return;
        if (req.status != 200 && req.status != 304) {
            console.log('HTTP error ' + req.status);
            return;
        }
        callback(req);
    }
    if (req.readyState == 4) return;
    req.send(postData); 
}

Here i call the send function

var insert = 'id=1&type=insert';
CLib.send(insert, function(data) {
    console.log(data);
});

Is it possible to make Cross Domain requests in IE?
How i can leave behind this part, without using any other library like jQuery?

  • 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-08T04:38:44+00:00Added an answer on June 8, 2026 at 4:38 am

    Thanks a lot @Esailija who inform me that i can’t make set request headers with the XDomainRequest.

    So i tried other methods and solutions also and i finally came back with a simpler method:
    changed the POST requests to GET and everything working fine after some small changes.

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

Sidebar

Related Questions

I am using this AJAX proxy for cross-domain AJAX requests: http://www.daniweb.com/code/snippet494.html . It works
Getting this error on chrome while trying to make cross-domain requests with GWT application.
I try to make a apps that need barcode scanner, i already can get
I try to make a registration form. When user post the fields, i check
I try to make Ext.Data.Store working... With a normal proxy it works great: var
I am trying to make a cross domain HTTP request to WCF service (that
I'm having a hard time trying to make jquery.form with a cross-domain request. I'm
Im trying to make a cross domain request to a web service via jquery
I have a json file hosted on my server. When I try to make
I wonder how can I make a cross domain request from a gwt application

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.