Click here to Skip to main content
12,403,699 members (74,452 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: PHP Ajax buttons session Firefox , +
Hello all

My website found here has two buttons. Both return videos from a tumblr blog using the tumblr api. I display 4 videos at a time,If i click the 'Forward' button it will call the php function(blogFunction.php) which will return the next 4 videos. The 'back' button will go back to the previous 4 videos.

The problem lies in that when I press 'Forward' in chrome, the videos do not change. The back button works fine. This problem only persists in Chrome. Firefox and Internet Explorer work fine. I noticed if I click the 'Forward' button twice really fast, it will work as intended.

I have the latest versions of Chrome and Firefox and IE8.

I would be incredibly happy if someone can help me here. Really happy!

My code.

Index.php

<?php 
 session_start();
 $_SESSION['views'] = 0;
 ?>


my blogFunction.php file

<?php 
session_start();
if(isset($_POST['action']) && !empty($_POST['action'])) {
    $action = $_POST['action'];
	
    switch($action) {
        case 'test1' :  blogforward();break;
		 case 'test2' :  blogback();break;
    }
}
 

	function blogforward(){	
 
		$request_url = "http://retrovate.tumblr.com/api/read?type=posts";
		$xml = simplexml_load_file($request_url);
 
		 $_SESSION['views'] = $_SESSION['views']+ 3;
		$a = $_SESSION['views'];
		$b = $a+3;
		echo "A = ".$a;
		echo "B = ".$b;
		
		for ($i	= $a; $i <= $b; $i++) {
				echo '<h2>'.$xml->posts->post[$i]->{'regular-title'}.'</h2>';
				echo '<br>';
				echo $xml->posts->post[$i]->{'regular-body'};
				echo '<br>';
				echo '<br>';
		}	 
		
	}
	
	
	function blogback(){
	
		$request_url = "http://retrovate.tumblr.com/api/read?type=posts";
		$xml = simplexml_load_file($request_url);
 
		$_SESSION['views'] = $_SESSION['views']- 3;	
		$a = $_SESSION['views'];
		$b = $a+3;
		echo "A = ".$a;
		echo "B = ".$b;
		
		
		for ($i	= $a; $i <= $b; $i++) {
				echo '<h2>'.$xml->posts->post[$i]->{'regular-title'}.'</h2>';
				echo '<br>';
				echo $xml->posts->post[$i]->{'regular-body'};
				echo '<br>';
				echo '<br>';
		}	
	
	}
?>
Posted 22-Jan-12 16:10pm
Mactm309

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 22 Jan 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100