Page 1 of 2 12 LastLast
Results 1 to 15 of 16

Thread: XMLhttprequest stopping and getting access denied

  1. #1
    Join Date
    Feb 2011

    XMLhttprequest stopping and getting access denied

    I am having some security problems and need some help..

    a little backstory.. I had the script running fine on my computer. . transfered them to my laptop, and the script still found and parses the xml like it should. however, i zipped them and sent it back to myself and now all the values come back undefined. .

    here is the script. .
    function loadXMLDoc(dname)
    if (window.XMLHttpRequest)
    xhttp=new XMLHttpRequest();
    xhttp=new ActiveXObject("Microsoft.XMLHTTP");
    return xhttp.responseXML;

    var xmlDoc = loadXMLDoc("nhl_standings_xml.xml");
    var x = xmlDoc.getElementsByTagName("nhlall");
    fairly straight forward and simple.. but values of x[0].textContent is coming back undefined.. i have all files (html, js, and xml) in the same folder on my desktop. they worked perfectly fine before when they were just on my desktop.. but now that won't even work. :/ help please

  2. #2
    Join Date
    Mar 2009
    May I suggest that after the line:
    you include the lines:
    alert(xhttp.readyState + "---" + xhttp.status);  //its its anything other than '4---200' this will give you the key to the error
    alert("the xml data is: " + xhttp.responseXML);  //has it sent any XML data at all
    alert("the response text is: " + xhttp.responseText); did it send any text back
    Sometimes it is the case that that the responseXML will be empty, or undefined, but the information will be in the reponseText.

    PS-- Sorry for the hasty response--I was looking at the content of your post rather than the title. Did you indeed get an xhttp.status code that indicated that access was denied?
    Last edited by Tcobb; 02-01-2011 at 04:21 PM.

  3. #3
    Join Date
    Feb 2011
    hello, it is very smart to test it in this way, but i received no alerts in the script.

    it is very strange indeed. and my brain is about to bleed from picking over it for two days. ;p

    IE and opera(as well as chrome and i assume firefox) are all giving me security errors at the line i stated above (when i pull up dev tools debugger).. a quick search on google and i pull up that i am crossing domains, yet all my files are local and in the same directory. :?

    would setting up apache and testing it help at all do you think? it was all working perfectly before i zipped them

  4. #4
    Join Date
    Feb 2011
    disregard my last message please:

    i got the following results
    1 4---0
    2 the xml data is: [object XMLDocument]
    3 the response text is:

  5. #5
    Join Date
    Mar 2009
    Usually when the 'status' equals zero this means it came from a local file rather than being processed by a server.

    And yes--it might help to fire up Apache on your box and run it through there.

    Another avenue to pursue is to compare the files--the original ones and the ones that were produced from having their zipped versions unzipped.

  6. #6
    Join Date
    Feb 2011
    the files are coming locally - is there something wrong with that? why did it work fine a few days ago on all browsers without touching code? is it possible the browsers updated since then? sorry for so many question.. so frustrated.. should i somehow process them through a local server instead? (i will try apache here in a bit -- see if anything works out)

    interestingly, what i said beforehand isn't true. everything is working as it should in firefox, but not chrome, ie, or opera ..

  7. #7
    Join Date
    Dec 2003
    Bucharest, ROMANIA
    Quote Originally Posted by shawnku View Post
    the files are coming locally - is there something wrong with that?
    AJAX requests (same as any classical submit) will not work locally, unless you install a server (like Apache or IIS) on your computer and run your files under that server.

  8. #8
    Join Date
    Dec 2010
    Quote Originally Posted by Kor View Post
    AJAX requests (same as any classical submit) will not work locally, unless you install a server (like Apache or IIS) on your computer and run your files under that server.
    You'll need a server to run PHP etc, but I have no trouble running AJAX requests under the file:/// protocol.
    This routine displays its own source:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
     <title>Load Own Source File</title>
    <form action='#'>
     <textarea id='ta1' cols='60' rows='20'></textarea>
    <script type="text/javascript">
    /* <![CDATA[ */
    req = new XMLHttpRequest();
    req.onreadystatechange = function() 
     if( this.readyState == 4 && this.status == ( /$http/.test( location.href ) ? 200 : 0 ) )
      document.getElementById( 'ta1' ).value = this.responseText; 
    req.open( "GET", location.href, true );
    req.send( null );
    /* ]]> */

    Q: I found this code...
    A: Then find its author.

  9. #9
    Join Date
    Dec 2003
    Bucharest, ROMANIA
    Well, yes. Some browsers accept request even when the status of the document is 0, not 200. But somehow it looks safer to test locally under an installed server.

    Now, back to the main problem:
    Quote Originally Posted by shawnku
    but values of x[0].textContent is coming back undefined
    I bet you are using an old version of IE on your laptop. Either upgrade your IE, or better use alternatively the innerText IE property. Rough code:
    var text
    else if(element.innerText){

  10. #10
    Join Date
    Feb 2011
    all browsers are runnign thsi script fine but IE8.. i ahve them all hosted locally on apache

  11. #11
    Join Date
    Mar 2009
    And what kind of xhttp.readyState and xhttp.status messages are you getting on IE8?

  12. #12
    Join Date
    Feb 2011
    just tried oth of them and interestingly it's giving me a readystate of 4, and a status of 200 on all browser's including ie. doesnt that mean it should be working loading and executing properly?

  13. #13
    Join Date
    Feb 2011
    i have been reading that IE doesnt really like .textContent , which i am using .. is there any good alternatives to it?

  14. #14
    Join Date
    Mar 2009
    I don't really know what '.textContent' is--what are the values of your xhttp.responseText and xhttp.responseXML? That's the key. Your original problem was getting the data to begin with. That now apparently is solved.

    What you do with the data is now up to you.

  15. #15
    Join Date
    Feb 2011
    it seems you are right.

    the value in order as you listed them are '4' and '200' .. which seems like it's normal..

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.13485 seconds
  • Memory Usage 3,015KB
  • Queries Executed 15 (?)
More Information
Template Usage (37):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (4)bbcode_code
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (15)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (15)postbit
  • (15)postbit_onlinestatus
  • (15)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (73):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates