Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Sep 2014
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    jQ code working in Chrome but not IE11

    Preface: I'm pretty sure this issue starts and ends with a knowledge gap on my part.

    This is the code that works in Chrome and not IE11:

    Code:
    $.getJSON('cards.json',function(c){
      var output="<table>";
    
        //some stuff happens
    
        output += "</table>";
        $("#cards").html(output);
    });
    When I opened Dev Tools within IE, the page sometimes broke at the $.

    After looking for about 2 hours (off and on since I'm at work) the most promising solution seemed to be to add some detail to the outside of the existing code.

    Code:
    (function() {
      $.getJSON('cards.json',function(c){
        var output="<table>"; 
    
          //some stuff happens
    
          output += "</table>";
          $("#cards").html(output);
      });
    })(jQuery);
    Now, the page doesn't break at the same line of code, but the stuff inside the $.getJSON function doesn't happen. Can someone point me in the right direction so I'll know how to fix this in the future?

  • #2
    New to the CF scene
    Join Date
    Sep 2014
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    OK, I can't edit the post, so here's the corrected code...

    $.getJSON('cards.json',function(c){
    var output="<table>";
    //some stuff happens
    output += "</table>";
    $("#cards").html(output);
    });

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,074
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Did you post your code correctly? You have syntax error on the code. I highlighted it in red.
    Code:
    $.getJSON('cards.json',function(c) {
        var output="<table>";
        //some stuff happens
        output += "</table>";
        $("#cards").html(output);
    });
    Check the response of the ajax request in the Network tab in IE11 and see if you are getting back a valid JSON object.
    Check this also: jquery - Problem with $.getJSON on IE - Stack Overflow
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #4
    New to the CF scene
    Join Date
    Sep 2014
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    OK, I tried the $.ajax version, and none of the browsers worked. (I added Firefox for testing)

    I checked the network settings (per your suggestion), and in IE I never see a call for the 'cards.json' file. I DO see it in the Chrome network log, though.

    In Firefox, I don't see any calls other than the jquery min file, but there is an alert that the .json file isn't well formed. I don't know for sure, but maybe that's a second issue that IE is not willing to work around.

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,074
    Thanks
    0
    Thanked 256 Times in 252 Posts
    In IE11, you have to enable network traffic capturing, that green triangle icon or F5.

    Do you have a link to your site?
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #6
    New to the CF scene
    Join Date
    Sep 2014
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I was actually just running it on my PC from a flash drive. I could put it on a site, if that might be the reason it isn't working.

  • #7
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,074
    Thanks
    0
    Thanked 256 Times in 252 Posts
    You're running the page from local file (e.g. file:///C:/)? You should run it on a local webserver and load the page via http://localhost/
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • Users who have thanked glenngv for this post:

    jasotastic (09-12-2014)

  • #8
    New to the CF scene
    Join Date
    Sep 2014
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by glenngv View Post
    You should run it on a local webserver and load the page via http://localhost/
    Well, that seems silly to me, but it worked. Thank you for that advice.


  •  

    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
    •