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 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    AJAX and IE8 Doing my head in please help!

    Hi Guys and Girls,

    i am currently working on a project and have noticed that in ie8 when loading a php file using AJAX / JQuery.load() it will not load if the php contains and <script> tags!!!

    Only IE8 ????

    If i remove the scripts from within the php file it works??

    Any suggestions below is the code I'm using to load the php file

    Code:
    var parts = window.location.href.split('?', 2);
    
    // After calling split(), 'parts' is an array with two elements:
    // parts[0] is 'sometext'
    // parts[1] is '20202'
    
    var the_text = parts[0];
    var the_num  = parts[1];
    
    $(document).ready(function() {
     	 $("#dealsystem").load('assets/snippets/bogof/dealsystem.inc.php?'+the_num);
       var refreshId = setInterval(function() {
          $("#dealsystem").load('assets/snippets/bogof/dealsystem.inc.php?'+the_num);
       }, 10000);
       $.ajaxSetup({ cache: false });
    });
    Thanks in advance and sorry for excessive ????

  • #2
    Regular Coder
    Join Date
    Jan 2008
    Location
    Geneva, Switzerland
    Posts
    413
    Thanks
    12
    Thanked 29 Times in 29 Posts
    Why would you need to have <scripts> in your php page? Can't you find a way to have those scripts in your js page and have only PHP in your php pages?
    Chuck Norris counted to infinity.
    Twice.

  • #3
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am using the php to pull events from mysql and to then output the names followed by a count down timer for which the variables are being generated within the while loop. Code below:

    Code:
    echo '<script type="text/javascript">';
    
    	$result2 = mysql_query("SELECT * FROM deal_detail, deal_times, vendor_details WHERE deal_detail.id = deal_times.deal_id AND deal_detail.vendor_id = vendor_details.id AND category_id = '$category' AND detail_approved = 1 AND payment_approved = 1 AND final_approval = 1  AND $phpdate = 1 AND start_date < now() AND end_date > now() AND $daystart < now() AND $dayend > now() GROUP BY deal_times.deal_id  ORDER BY $dayend $dir");
    
    	while($row2 = mysql_fetch_array($result2))
    	  {
    		
    		$phpdate2 = strtotime( $row2[$phpdate.'_end'] );
    	
    		
    		$mysqldate = date( 'F d, Y H:i:s', $phpdate2 );
    		
    		echo'		
    
    					var futuredate'.$timeid2.'=new cdtime("countdowncontainer'.$timeid2.'", "'.$mysqldate.'")
    					futuredate'.$timeid2.'.displaycountdown("days", formatresults)
    
    				
    					';
    					 $timeid2 = $timeid2+1;
    		}
    	
    	echo '	</script>';
    It works in every other browser just not in IE8 and the crazy bit is if i remove the <script> tag it outputs the results just not the timer. Add the script tag back in and BOOM no output ....

    Even crazier than that is i have a similar system on another page which has no issues ....

  • #4
    Regular Coder
    Join Date
    Jan 2008
    Location
    Geneva, Switzerland
    Posts
    413
    Thanks
    12
    Thanked 29 Times in 29 Posts
    Well, I can't say what causes issues with IE8 (and cannot test under IE right now) but...

    I wouldn't do it that way anyway.

    What I would do is: Have the JS to do an AJAX call to the PHP page, and have PHP to return all you need to construct your timer - but - I would construct the timer on the JS side and not on the PHP side.

    Hope this makes sense...
    Chuck Norris counted to infinity.
    Twice.

  • #5
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I guess my question is why if i include the php directly on the page does it work but loading it through AJAX it doesn't?

  • #6
    Regular Coder
    Join Date
    Jan 2008
    Location
    Geneva, Switzerland
    Posts
    413
    Thanks
    12
    Thanked 29 Times in 29 Posts
    Yes, I understand your question and I am sorry but I can't tell. Still I think the way you are doing it is not "best-practice" but I can't really tell you why it doesn't work.
    Chuck Norris counted to infinity.
    Twice.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •