SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Guru Ruben K.'s Avatar
    Join Date
    Jun 2005
    Location
    Alkmaar, The Netherlands
    Posts
    693
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    XMLHttpRequest problem

    Code:
    function updateSpy()
    {
    	var request = makeRequest();
    	request.open( 'get', 'http://localhost/spy/xml.html' );
    	
    	request.onreadystatechange = function()
    	{
    		if( request.readyState == 4 )
    		{
    			var actions = request.responseXML.getElementsByTagName( "actions" )[0];
    			alert( actions.childNodes.length );
    		}
    	}
    	
    	request.send('');
    }
    For some reason, this doesn't work and the error returned is 'Error: uncaught exception: Permission denied to call method XMLHttpRequest.open'

    I don't understand why this happens and I don't know how I would fix this error. Could anyone please assist me?

  2. #2
    I ♥ PHP
    Join Date
    Jul 2003
    Location
    Melbourne, Australia
    Posts
    579
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you post your makeRequest() function please?

    Regards,
    Jordan

  3. #3
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    post makeRequest code

  4. #4
    I'm not a human
    Join Date
    Aug 2006
    Location
    India
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    If you are using XMLHttpRequest object, the open method should have three arguments .

    The third arg is missing in your function.

    The syntax will be,

    Code:
     xmlHttp.open("GET",url,true)

    The third argument says whether the request is asynchronous (in the case of AJAX) or synchronous.

    True for asynchronous and false for synchronous.
    Regards,
    Vijay
    Follow me on twitter @vijaycbe
    World Holiday Calander || My Cricket Blog

  5. #5
    SitePoint Guru Ruben K.'s Avatar
    Join Date
    Jun 2005
    Location
    Alkmaar, The Netherlands
    Posts
    693
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kvijayhari
    Hi,

    If you are using XMLHttpRequest object, the open method should have three arguments .

    The third arg is missing in your function.

    The syntax will be,

    Code:
     xmlHttp.open("GET",url,true)

    The third argument says whether the request is asynchronous (in the case of AJAX) or synchronous.

    True for asynchronous and false for synchronous.
    This solved my problem, thank you!

  6. #6
    SitePoint Member
    Join Date
    Jan 2006
    Location
    Sydney, Australia
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Please read my PM.

  7. #7
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Permission denied error sounds like you are trying to open a page that is not in the same domain as the calling URL


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
  •