[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


xhr IE send error

Posted on 2012-08-12
Medium Priority
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
  • 2
LVL 35

Accepted Solution

Robert Schutt earned 2000 total points
ID: 38286225
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
ID: 38286231
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
ID: 38286248
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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
This article discusses how to implement server side field validation and display customized error messages to the client.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

834 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