SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Aug 2003
    Location
    IL
    Posts
    292
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jQuery Not Working Sometimes. Help Problem Solving.

    Okay, I have some jQuery that calls a php file. I have my php file echo out some data to an error log every time it is pulled up to see if it is actually being called, and most times it is, except for the occasional breakdown. I've then been able to track it down to my jQuery and I have an alert right before my $.getJSON that will show me the values of my variables (to make sure that I have data) and it always works (even when the occasional breakdown happens) so I'm theorizing that there must be something quirky with my $.getJSON, maybe I'm missing a comma or something? Either way, I'm using IE 7 (mandated by the company that I work for) and maybe there's a glitch with that browser? I'm just throwing things out here... Here's my code, can someone help me figure this out somehow? Write to a log file or something? I'm at my wits end with this... Thanks in advance!:
    Code:
    $("#days<?php echo $JavaCnt;?>").change(function(){
     var r12     = $('#r12<?php echo $JavaCnt;?>').attr('value');
     var std     = $('#std<?php echo $JavaCnt;?>').attr('value');
     var fnlss     = $('#fnlss<?php echo $JavaCnt;?>').attr('value');
     var ordq52     = $('#ordq52<?php echo $JavaCnt;?>').attr('value');
     var tinv     = $('#tinv<?php echo $JavaCnt;?>').attr('value');
     var id     = $('#id<?php echo $JavaCnt;?>').attr('value');
     var days     = $('#days<?php echo $JavaCnt;?>').attr('value');
     var userid = '<?PHP ECHO $UserID;?>';
     var year = '<?PHP ECHO $Year;?>';
     var ceiling = '<?PHP ECHO $Ceiling;?>';
     var floor = '<?PHP ECHO $Floor;?>';
     var diffallowed = '<?PHP ECHO $DiffAllowed;?>';
     alert("id="+ id + "&days=" + days + "&userid=" + userid + "&year=" + year + "&ceiling=" + ceiling + "&floor=" + floor + "&diffallowed=" + diffallowed + "&r12=" + r12+ "&std=" + std+ "&fnlss=" + fnlss+ "&ordq52=" + ordq52+ "&tinv=" + tinv)  
     
      $.getJSON('AJ_SSAnalysis.php', {'id' : id, 'days' : days, 'userid' : userid, 'year' : year, 'ceiling' : ceiling, 'floor' : floor, 'diffallowed' : diffallowed, 'r12' : r12, 'std' : std, 'fnlss' : fnlss, 'ordq52' : ordq52, 'tinv' : tinv}, parseInfo);
     
       function parseInfo(data)
        {
     
         if(data){
          $('div#txtHintA<?php echo $JavaCnt;?>').html(data.QTY);
          $('div#txtHintB<?php echo $JavaCnt;?>').html(data.STD);
          $('div#txtHintC<?php echo $JavaCnt;?>').html(data.TURNS);
             if(data.PHPalert){
              alert(data.PHPalert);
           window.location='<?php echo $_SERVER["PHP_SELF"]."?usid=".$_GET['usid']."&nav_pn=".$_GET['nav_pn'];?>';
          }
         }
     
        }
     } 
     );
    FYI,
    I have posted this question on a few other forums not to be annoying but because I'm at my wits end and need help real bad, i appreciate your understanding:
    http://www.codingforums.com/showthre...35#post1074935
    http://forums.devshed.com/javascript...ng-803769.html

  2. #2
    SitePoint Addict
    Join Date
    Aug 2003
    Location
    IL
    Posts
    292
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    FYI,
    I've noticed in a nother place that the exact same thing happens with this piece of code as well:
    Code:
    $("#remarks<?php echo $JavaCnt;?>").change(function(){
     var id     = $('#id<?php echo $JavaCnt;?>').attr('value');
     var remarks     = $('#remarks<?php echo $JavaCnt;?>').attr('value');
     remarks = encodeURIComponent(remarks);
     var userid = '<?PHP ECHO $UserID;?>';       
      $.getJSON('AJ_SSAnalysis.php', {'id' : id, 'remarks' : remarks, 'userid' : userid}, parseInfo);
     } 
     );
    Sometimes it works and sometimes it doesn't. Whatever I'm doing it is consistent, that's for sure. Again, I'm using IE7 so if there's a bug between JSON and IE7 please let me know, or if I'm missing a single quote or comma somewhere...

  3. #3
    SitePoint Addict
    Join Date
    Aug 2003
    Location
    IL
    Posts
    292
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So somewhere I read that IE has issues with the cache when it comes to JSON. I just don't know enough about this stuff to get it to work.
    jQuery’s getJSON failing randomly in Internet Explorer | i.justrealized
    If I just put
    Code:
    $.ajaxSetup({ cache: false });
    in my code right before the $.getJSON line is that the proper syntax? Is that the right place for it and should it work?


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
  •