SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard
    Join Date
    Apr 2002
    Posts
    2,322
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    does ie7 upload cookies to server on ajax style requests?

    are cookies uploaded to the server on ajax style requests in ie7 (and other ie's)? i know safari and firefox upload them.

    does this have any relevance?:
    Cookie blocked/not saved in IFRAME in Internet Explorer
    http://stackoverflow.com/questions/3...ernet-explorer
    (i'm not using an iframe)

    edit: just to clarify, i'm asking about cookies which have already been set successfully in ie7, when there's an ajax style form submission using http request, does the cookie data, or at least should it, go along with the http reuqest? (does with other browsers for sure) (i don't have easy access to ie hense why i'm asking rather than just checking -- what i suppose i'll have to do is make a simple stripped down version of the code i'm using to test this out)

    this is the code i'm using for the ajax request. pretty much verbtim from the code in o'reilly's javascript definitive guide book.

    Code:
    HTTP={};
    HTTP._factories=[
        function(){ return new XMLHttpRequest(); },
        function(){ return new ActiveXObject("Msxml2.XMLHTTP"); },
        function(){ return new ActiveXObject("Microsoft.XMLHTTP"); }
    ];
    HTTP._factory=null;
    HTTP.newRequest=function(){
        if(HTTP._factory!=null) return HTTP._factory();
        for(var i=0; i < HTTP._factories.length; i++){
            try {
                var factory=HTTP._factories[i];
                var request=factory();
                if(request!=null){
                    HTTP._factory=factory;
                    HTTP.XMLHttpRequestSupported=true;
                    return request;
                }
            }
            catch(e){
                continue;
            }
        }
        HTTP._factory=false;
        return false;
    }
    HTTP.get=function(callback, options){
    	var url="includes/postcode-ajax.php";
        var request=HTTP.newRequest();
        if(request==false) return false;
        var div=document.getElementById("in");
    	div.insertBefore(activityImage, div.firstChild.nextSibling);
        var n=0;
        var timer;
        timer=setTimeout(function(){request.abort();if(options.timeoutHandler) options.timeoutHandler(url); }, options.timeout);
        request.onreadystatechange=function(){
            if(request.readyState==4){
                if(timer) clearTimeout(timer);
                if(request.status==200) callback(request.responseText);
                else {
                    if(options.errorHandler)
                        options.errorHandler(request.status,
                                             request.statusText);
                    else callback(null);
                }
            }
            else if(options.progressHandler){
                options.progressHandler(++n);
            }
        }
        var target=url;
        target += "?" + options.parameters;
        request.open("GET", target, true);
        request.send(null);
        return true;
    };
    Last edited by johnyboy; Mar 4, 2009 at 05:08.

  2. #2
    SitePoint Addict
    Join Date
    Sep 2007
    Posts
    371
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, cookies are sent when a browser makes an ajax request. This behaviour is same for all browsers.

  3. #3
    SitePoint Wizard
    Join Date
    Apr 2002
    Posts
    2,322
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    right, thanks. the problem must be something else then. it works/doesn't-work intermittently on ie7 i've found out, goes through little sretches of working then not working. can not work out what it hinges on. anyway, thanks for confirming that.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •