Results 1 to 6 of 6

Thread: XML and Javascript loading problem

  1. #1
    Join Date
    Apr 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default XML and Javascript loading problem

    Hi, I am building a website for a small business and they want to be able to add pictures to galleries and delete/change. The person that will be doing this has zero programming knowledge so I wanted to make this harmless. I didnt want him going into my html code... Anyways, here is my problem.

    I have created an xml file so that to change a picture, you just open it with an editor and change the name of the pictures to the ones that you want to view on that page. My javascript reads this file, loops through it, and creates a dynamic table with the pictures.

    This works probably 85% of the time and the other 15%, i get a javascript error and the pictures do not load. But, if i refresh the page, they load just fine... I have 4 pages that uses this script and it usually occurs when I am navigating through my site...

    Can someone please help?

  2. #2
    Join Date
    Dec 2007
    Location
    Ankara, Turkey
    Posts
    160
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Default

    You should give more details. First of all if possible your code and a sample XML data. Also in which browsers' which versions do you experinece this problem? What is the error you get?

  3. #3
    Join Date
    Apr 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi, sorry for the lack of clarity. I have attaced 2 files. tractor.txt is the html file and tractor_pics.txt is the xml file. I am experiencing the problem in firefox, ie6, and ie7.

    I would appreciate any help you could give me...

  4. #4
    Join Date
    Dec 2007
    Location
    Ankara, Turkey
    Posts
    160
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Default

    You should be sure that your XML object has created and loaded properly before calling loadMainPics function. This seems to be the source of the problem. Why not using a ready script for AJAX calls which proivdes a cross-browser onload event?

  5. #5
    Join Date
    Apr 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you for the help on this matter.

    Why does it create the xml object correctly sometimes and not at all other times? I tried putting it in an onload event, but when I did that my pictures wouldn't get loaded. I didnt get any errors, they just didnt show up.. Weird stuff.

    I tried putting the code that creates the xml object in a function and then if succeeded go to loadMainPics but, like I said, pics didnt show up..

  6. #6
    Join Date
    Dec 2007
    Location
    Ankara, Turkey
    Posts
    160
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Default

    You know, browsers do cache things. Probably you do not get an error when it very quickly loads from cache but you get an error when it really tries to fetch the data from server. I suggest you to use XMLHTTPRequest object which has an "onReadyStateChange" event

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
  •