Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Weird issue, where its running code AFTER, but not BEFORE!

Status
Not open for further replies.

youradds

Programmer
Jun 27, 2001
817
GB
Hi,

Man, this is screwed up :( I've been tearing my hair out over it for the last few hours. If you go here:


You will see a google map, with markers and a sidebar. Everything works here perfectly in all browsers (appart from some weird error about main.js, in IE7 and 8!). When you click the "Contact Propertie" link, it opens up a contact form using AJAX. Again, no problem so far. That is - until you try it in IE 7 and 8. Works perfectly in IE 9+

The code that shows the "AJAX loading" image, is this:

Code:
    function getData2(dataSource, divID, ID) {
        alert("HERE NEW 1");
        go2ByScroll("anch" + ID);
        jQuery('#' +divID).html("<img src='/links/static/ajax-loader.gif'>");
        var the_url = dataSource + ";divID=" + divID;
        jQuery.ajax({
          url: the_url,
          success: function(data){
            document.getElementById(divID).innerHTML = data;
          }
        });   
    }

When you click the "Contact Propertie" button, it must be calling that function - as the image gets shown, using:

Code:
        jQuery('#' +divID).html("<img src='/links/static/ajax-loader.gif'>");

I've verified that its indeed using this, by changing it to:

Code:
        jQuery('#' +divID).html("TEST <img src='/links/static/ajax-loader.gif'>");

..and sure enough, when I click the Contact button, it comes up with "TEST" and then the "ajax loading" image.

But what I don't get, is why oh why its neglecting to run other parts of the code. If I change that function to just:

Code:
    function getData2(dataSource, divID, ID) {
        alert("HERE NEW 1");
        jQuery('#' +divID).html("<img src='/links/static/ajax-loader.gif'>");
    }

..again, the image is shown - but no "alert" comes up. I'm really pulling my hair out on this one :( Any suggestions are much appreciated!

Cheers

Andy
 
Wow, that was a sod to catch. It turns out the AJAX content being returned had an extra </div> in it... which was causing it for some reason to not work with the html() and innerHTML functions of Javascript.

Just in case anyone else comes across the problem in the future ;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top