[Javascript] IE, Firefox, and XMLHTTPRequest

Matt Murphy matt.murphy at thermofisher.com
Fri Dec 29 14:05:28 CST 2006


as a followup, it seems the part causing me trouble is this:
 
        http_request.open('POST', url, true);
        http_request.send(null);
 
all the data is being passed with the url, so I'm running into GET
limitations. 
 
instead of passing this data with the url, I should pass it in the
send() part. The big question I have, is what to put in send()? I can
just pass in my data, but then how do I retrieve it on the other end? 
 
I'm using php, so if this is post data, using php I'd do $data =
$_POST['name']; But the question is, how do I specify what name is in my
http_request.send() function? 
 
Thanks,
 
Matt

________________________________

From: javascript-bounces at LaTech.edu
[mailto:javascript-bounces at LaTech.edu] On Behalf Of Matt Murphy
Sent: Friday, December 29, 2006 1:11 PM
To: Javascript at LaTech.edu
Subject: [Javascript] IE, Firefox, and XMLHTTPRequest


So, I'm a bit of a javascript n00b. I've got a script that uses
XMLHTTPRequest, though that part I did not write. (contributed with
permission) The firefox version works fine with the sample data I'm
using, but the IE version fails if the input string is too long. 
 
here is the XMLHTTPRequest part: 
 
function ajaxme(url)
{
 
        http_request = false;
 
        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new
ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }
 
        if (!http_request) {
            alert('Giving up :( Cannot create an XMLHTTP instance. Your
browser may be too old for this application.');
            return false;
        }
        http_request.onreadystatechange = hitMe;
        http_request.open('POST', url, true);
        http_request.send(null);
    }
 
and this is how I call it in my page:
 
ajaxme('notes.php?action=insnotedb&table='+tablename+'&note='+note+'&con
n='+conn+'&datefield='+datefield+'&connid='+connid+'&data='+escape(data)
);
 
if data is long, IE barfs on this line:
        http_request.open('POST', url, true);
but firefox is fine with long data. 
 
For short stuff (5 paragraphs?) they're both fine.
 
Using a form to POST the same data (4x longer than is barfed on by IE)
works in both browsers. 
 
Is there a limitation to the size of http request IE will accept with
XMLHTTP? Any idea what's going on? 
 
Thanks,
 
Matt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20061229/1f0a3798/attachment.htm>


More information about the Javascript mailing list