Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

XMLHttpRequest question.

  • 01-01-2005 9:31am
    #1
    Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭


    Ok when I run this the responseText is set as "undefined". It should be text. Anyone know what I'm missing?
    var gXMLHttpRequest;
    
    function loadUp() {
    	gXMLHttpRequest = new XMLHttpRequest();
    	gXMLHttpRequest.onload = updateID;
    	gXMLHttpRequest.open("GET", "http://members.boards.ie/dokkaebi/pmtest.txt");
    	gXMLHttpRequest.send(null);
    
    //	window.setTimeout(loadUp, 1800000);
    }
    
    //window.setTimeout(loadUp, 1000);
    
    function updateID()
    {
      	var pageText = XMLHttpRequest.responseText;
      	alert(pageText);
    }
    


Comments

  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    Ack so bloody simple, amazed I missed it :(

    Someone at mozilla told me...

    var pageText = gXMLHttpRequest.responseText;


  • Registered Users, Registered Users 2 Posts: 1,785 ✭✭✭Farls


    Always the simple ones take the longest to figure! Surprised a noob didn't get it.

    "School boy errors" eh!

    Farlz


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    Actually my next question is.. How do you pass a cookie to the site your accessing?

    Trying to access usercp, however all it gets is the not logged in page, yet the browser is logged in.


  • Closed Accounts Posts: 9,314 ✭✭✭Talliesin


    Hobbes wrote:
    Actually my next question is.. How do you pass a cookie to the site your accessing?
    HTTP Headers for the request can be set with the setRequestHeader method.


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    Cheers. appears there is a little more involved then that. I'll post solution once I get it working.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    Here it is. Once you activate the cookie manager and pull in the cookies you want then the XMLHttpRequest will pull the required cookies from that. Example below pulls all boards.ie cookies before requesting userCP.
    function getQueryString() {
    	// Get the cookie.
    	var ioService = Components.classes['@mozilla.org/network/io-service;1'].getService(Components.interfaces.nsIIOService);
    	var cookieManager = Components.classes["@mozilla.org/cookieService;1"].getService(Components.interfaces.nsICookieService);
    	var uri = ioService.newURI("http://www.boards.ie", null, null); 
    	cookieString = cookieManager.getCookieString(uri, null);
    	
    	gXMLHttpRequest = new XMLHttpRequest();
    	gXMLHttpRequest.onload = updatePMCheck;
    	
    	gXMLHttpRequest.open("GET", "http://www.boards.ie/vbulletin/usercp.php?");
    	gXMLHttpRequest.send(null);
    }
    


Advertisement