xhr IE send error

Posted on 2012-08-12
Last Modified: 2012-08-13
I'm trying to use XHR POST, and all is working well except, well, in IE :(

IE doesn't like this line (Invalid Argument):


here's the whole snippet:

var data = ['perfs='+ navigationStart,  domLoading  ];

sendRequest('request.php', data);
            function sendRequest(url, postData) {
                        var req = createXMLHTTPObject();
                        if (!req) return;
                        var method = (postData) ? "POST" : "GET";
                        if (postData)
                                req.onreadystatechange = function () {
                                if (req.readyState != 4) return;
                                if (req.status != 200 && req.status != 304) {
                        if (req.readyState == 4) return;


                function createXMLHTTPObject() {
                        var xmlhttp = false;
                        var XMLHttpFactories = [
                                function () {return new XMLHttpRequest()},
                                function () {return new ActiveXObject("Msxml2.XMLHTTP")},
                                function () {return new ActiveXObject("Msxml3.XMLHTTP")},
                                function () {return new ActiveXObject("Microsoft.XMLHTTP")}
                        var len = XMLHttpFactories.length;
                        for (var i=0;i<len;i++) {
                                try { xmlhttp = XMLHttpFactories[i]();}
                                catch (e) {continue;}
                        return xmlhttp;

Open in new window

Question by:Kyle Hamilton
    LVL 35

    Accepted Solution

    To convert your data array to the type 'application/x-www-form-urlencoded' (which is what you're sending) you could (as a first step) replace line 20 by:

    Open in new window

    LVL 35

    Expert Comment

    by:Robert Schutt
    By the way, if it's working OK when you use XMLHttpRequest (in browsers like FireFox and Chrome presumably), then of course by all means, only use the 'old school conversion' to a string when using one of the ActiveX objects (in IE).
    LVL 25

    Author Closing Comment

    by:Kyle Hamilton
    Awesome - thank you. Did the trick!

    I ended up doing this:


    which gives me the standard comma, which I later use to explode the string in php.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
    I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now