www.webdeveloper.com
Results 1 to 3 of 3

Thread: loadXMLDoc cross domain issue ???

  1. #1
    Join Date
    Jun 2005
    Posts
    94

    loadXMLDoc cross domain issue ???

    Hi Friends,
    I am new to javascript and i am using this code to load an xml document.
    Code:
    xmlDoc=loadXMLDoc("schedule.xml");
    Now, I am tryng to convert this javascript program to a "widget". The widget does not allows me to upload an XML file, so when I try to change that XMLDoc statement to this:
    Code:
    xmlDoc=loadXMLDoc("http://www.somesite.com/schedule.xml");
    It's throwing errors because that method cannot access cross domains. Is there any other method that I can use instead of this??? I do not want to use AJAX, as I am not familiar to that language.


    Secondly, I tried doing to add the whole XML file as a variable but that did not work either
    Code:
    text = "<game><........></.......>............<......></......></game>";
    xmlDoc=loadXMLDoc(text);
    Any help would be greatly appreciated.

  2. #2
    Join Date
    May 2003
    Location
    Between Baltimore and DC
    Posts
    3,579
    JavaScript has a same domain policy, you can not call another domain.

    You would have to set up a serverside proxy on the server to fetch the file.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint] | twitter | linkedin | http://www.pascarello.com

  3. #3
    Join Date
    Jun 2005
    Posts
    94
    Thanks A1ien,
    But I have both of the documents in the same place. For example, this is the url which I am submitting for google widget:
    http://www.mysite.com/widget.xml

    And widget.xml has the loadXMLDoc method call like this:
    xmlDoc=loadXMLDoc("schedule.xml");

    So, don't you think it should load the schedule.xml document as it's on the same domain????

    I even tried this but did not worked either:
    xmlDoc=loadXMLDoc("http://www.mysite.com/schedule.xml");

Thread Information

Users Browsing this Thread

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

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



Recent Articles