jquery and $.getJSON - mozilla is working great, ie chokes

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

jquery and $.getJSON - mozilla is working great, ie chokes

Post by Luke »

I'm trying to use jquery to "get" a url and parse the json it returns. In firefox, it works seamlessly. Internet explorer chokes (what a shock!) Is there a specific header that needs to be returned by the url? Is there anything wrong with my json?

Code: Select all

{ 'img':'/mm5/public/images/products/100333.jpg' ,'bup':'/mm5/public/images/products/bup/100333.jpg' } 
How about my javascript?

Code: Select all

$(function(){

        $("#product-colors .loading span").ajaxStart(function(){

          $(this).html('Loading...');
          $(this).fadeIn('fast');

        });

        $("#product-colors .loading span").ajaxComplete(function(){

          $(this).fadeOut('slow', function(){

            $(this).empty();

          });

        });

        $("#product-colors .loading span").ajaxError(function(){

          $(this).html('<span class="error attention">Sorry, an error has occured</span>');
          $(this).fadeIn('fast');

        });

        $('#product-colors input:radio').focus(function(){

          var code = $(this).attr('value');

          $.getJSON("/widget/image-verify", {'Product_Code':code, bup:'1'}, function(json){

            if (json.img != 'false')
            {

              $('#main_photo img').attr('src', json.img);

            }

            if (json.bup != 'false')
            {

              $('#main_photo a.thickbox').attr('href', json.bup);

            }

          });

        });

      });
Image I HATE IE

Here's the url to the page:
http://store.tarmadesigns.com/product/a ... -wristband

Try toggling the color. It works so well in firefox. In Internet explorer sometimes the content on the right overlaps the image (WTF??) and the image swap is not working.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

Firefox is quite a bit more forgiving than IE in many ways!

instead of

Code: Select all

if (json.bup != 'false')
try

Code: Select all

if (json.bup != false)
(same for json.img)
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

I was hoping you'd show up here! :D I tried that. It's returning the string 'false' on failure. This is the strangest thing. Did you look at the site? See how one table cell is overlapping another? WTF? I have NEVER seen that happen. I plan on converting it to an all-css layout, but for the time being I'd just like it to work! :(

EDIT: wait, maybe I didn't try that... hang on.

EDIT AGAIN: Hmm... it appears that in IE it isn't sending the correct parameters or something, because it's returning false when it should return the path. :( I will have to tinker some more.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

Strange, it turns out IE didn't like the get method for some reason. I tried post and it works fine. But it's still doing that annoying table cell overlap thing. Anybody know what could be causing that?
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

It appears that the table cell overlap only happens after you click the image and it opens a thickbox (google it). So I guess thickbox is causing this problem some-how. I guess I'll try laying it out with CSS and see if that is handled better.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: jquery and $.getJSON - mozilla is working great, ie chok

Post by RobertGonzalez »

The Ninja Space Goat wrote:Image I HATE IE
+100. Amen to that!
Post Reply