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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:20:06+00:00 2026-06-02T18:20:06+00:00

I use my own custom AJAX library (I’m not interested in using jQuery, etc.),

  • 0

I use my own custom AJAX library (I’m not interested in using jQuery, etc.), which is working flawlessly in the following browsers:

  • Firefox 7
  • Chrome 14
  • IE 8
  • IE 8 (compatibility mode)

Using my custom AJAX library in the aforementioned browsers, I can make as many AJAX requests as I want, in any order, using GET and/or POST methods, and they all work flawlessly. Since a new AJAX object is created for every request (see code below), I can even have more than one AJAX request process simultaneously with success.

However, in Safari 5 an AJAX POST request only passes POST data to the server if it is the absolute first AJAX request to execute. Even if I execute the exact same AJAX POST request twice in a row, the POST data is only passed to the server during the first request. Here is the JavaScript in my custom AJAX library:

if (!Array.indexOf)
{
    Array.prototype.indexOf = function(obj) { for (var i = 0; i < this.length; i++) { if (this[i] == obj) { return i; } } return -1; };
}

function ajaxObject()
{
    if (window.ActiveXObject)
    {
        var activexmodes = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"];
        for (var i = 0; i < activexmodes.length; i++)
        {
            try
            {
                return new ActiveXObject(activexmodes[i]);
            }
            catch (e)
            {

            }
        }
    }
    else if (window.XMLHttpRequest)
    {
        return new XMLHttpRequest();
    }
    else
    {
        return false;
    }
}

function ajaxRequest(aURI, aContainerId, aPostData, aResponseType, aAvoidBrowserCache)
{
    // Initialize
    var xmlhttp = new ajaxObject();
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
        {
            if (aResponseType != "eval" && aResponseType != "EVAL")
            {
                // Show HTML for response
                document.getElementById(aContainerId).innerHTML = xmlhttp.responseText;
            }
            else
            {
                // Parse & execute JavaScript for response
                var responseText = xmlhttp.responseText;
                var startPos, endPos;
                for (var i = 0; i < responseText.length; i++)
                {
                    if (responseText.substring(i, i + 6) == "<eval>")
                    {
                        startPos = i + 6;
                        break;
                    }
                }
                for (var i = startPos; i < responseText.length; i++)
                {
                    if (responseText.substring(i, i + 7) == "</eval>")
                    {
                        endPos = i;
                        break;
                    }
                }
                textToEval = responseText.substring(startPos, endPos);
                eval(textToEval);
            }
        }
        else
        {
            try
            {
                if (xmlhttp.status != 0 && xmlhttp.status != 200)
                {
                    alert('Error ' + xmlhttp.status);
                }
            }
            catch (e)
            {
                // Handle IE8 debug "unknown error"
            }
        }
    }
    if (aAvoidBrowserCache != false)
    {
        // Combat browser caching:
        aURI = aURI + (aURI.indexOf("?") == -1 ? "?" : "&");
        theTime = new Date().getTime();
        aURI = aURI + theTime + "=" + theTime;
    }
    // Make request
    if (typeof aPostData == "undefined" || aPostData == null || aPostData == "")
    {
        // GET request
        xmlhttp.open("GET", aURI, true);
        xmlhttp.send();
    }
    else
    {
        // POST request
        var parameters = "";
        if (aPostData.constructor.toString().indexOf("Array") != -1)
        {
            // Use parameters passed as array
            for (var postCount = 0; postCount < aPostData.length; postCount++)
            {
                if (parameters != "")
                {
                    parameters = parameters + "&";
                }
                parameters = parameters + aPostData[postCount][0] + "=" + encodeURIComponent(aPostData[postCount][1]);
            }
        }
        else
        {
            // Use parameters passed as string
            parameters = aPostData;
        }
        xmlhttp.open("POST", aURI, true);
        xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlhttp.send(parameters);
    }
}

So for example, either of the following AJAX POST requests will pass POST data if they are the absolute first AJAX request (whether GET or POST); otherwise, the POST data is not passed:

ajaxRequest("test.aspx", "", [["name1","value1"],["name2","value2"]], "eval");

or

ajaxRequest("test.aspx", "", "name1=value1&name2=value2", "eval");

I have added debug statements all throughout my AJAX library, and the POST parameters are being created in the “parameters” variable as expected prior to each POST request. I have absolutely no idea why, only in Safari 5 (out of the mentioned browsers), I have this problem. Any ideas?

Thanks in advance!
Jesse

  • 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-02T18:20:07+00:00Added an answer on June 2, 2026 at 6:20 pm

    The reason the call is failing is because of a bug in Safari when working with Windows Authentication under IIS. Go to the Authentication settings of your website. Right click on Windows Authentication, choose providers and remove Negotiate, leaving NTLM which works fine. I haven’t tested Kerberos.

    This issue only appears in certain builds of safari.

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

Sidebar

Related Questions

I'm working on a custom CMS for my own use and was thinking about
I'm currently working on an AJAX site where we use custom HTML tags to
I am using the following code to make a custom checkbox with my own
how can I open a modal window using javascript only. I can't use own
I'm wrapping a library for my own use. To get a certain property I
I've subclassed QGraphicsItem into my own custom class, Hexagon. When I try to use
How can i use my own (custom) session value inside wordpress? For example: $_SESSION['myname']=4lvin
I have developed an app which uses my own custom keyboard (well, a view
I am trying to use my own custom image to represent my toolbar buttons,
In my current project I use my own custom allocators inspired by the article

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.