Author Topic: Javascript XMLHttpRequest cache help  (Read 548 times)

Xenos360

  • New Member
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Javascript XMLHttpRequest cache help
« on: August 05, 2010, 02:56:36 PM »
I got a add friend script going into javascript. In javascript I use XMLHttpRequest and send all the variables over to a .php file which adds everything to a database.


I go onto my desktop, which I do all my work on and when I click the link, it disappears but everything is added to the database.


Well one night I went onto my laptop and did the same thing (Same Operating System, Same Browser) And I clicked the same link too and it didnt go blank, it came back with "Friend Request Sent!"


So I looked up the problem and people say its the cache since on my desktop when it was broke, that cache was saved. I tried deleting cache in IE and everything and I still get the same thing, it just disappears! :/


Has anybody else had this problem? (Oh and I had my friend try it and his disappears) OH! and I have almost the same thing but its for the person you've added, its a accept or deny and it works fine for everything.






And heres the code if anybody wants to look at it
PHP Code: [Select]
function toggleFriend(rusereleId){
	
var 
ajaxRequest;
	
var 
eleId eleId;
	
var 
tuser ruser;
	
var 
cuser "<?php echo $session->username; ?>";


	
try{
	
	
ajaxRequest = new XMLHttpRequest();
	
} catch (
e){
	
	
try{
	
	
	
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
	
	
} catch (
e){
	
	
	
try {
	
	
	
	
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
	
	
	
} catch (
e){
	
	
	
alert("Your browser broke!");
	
	
	
return 
false;
	
	
	
}
	
	
}
	
}
	
ajaxRequest.onreadystatechange = function(){
	
	
if(
ajaxRequest.readyState == 4){
	
	
	
ajaxRequest.responseText;
	
	
	
document.getElementById(eleId).innerHTML ajaxRequest.responseText;
	
	
}
	
}
    
	
var 
queryString "?aj=tFriends" "&cuser=" cuser "&tuser=" tuser;
	
ajaxRequest.open("GET""http://gaming-unleashed.com/Pages/ajaxQueries.php" queryStringtrue);
	
ajaxRequest.send(null);
}



And the .php file
PHP Code: [Select]
// Toggling friends
if(isset($_GET['aj']) && ($_GET['aj'] == 'tFriends')){
	
$username htmlspecialchars($_GET['cuser'], ENT_QUOTES);
	
$tusername htmlspecialchars($_GET['tuser'], ENT_QUOTES);
	
if(
mysql_num_rows(mysql_query("SELECT * FROM `friends` WHERE `username` = '".$username."' AND `friend` = '".$tusername."'")) == 0){
	
	
mysql_query("INSERT INTO `friends` (username, friend, accepted) VALUES ('".$username."', '".$tusername."', 'No')");
	
	
echo 
'Friend Request Sent!';
	
} else if(
mysql_num_rows(mysql_query("SELECT * FROM `friends` WHERE `username` = '".$username."' AND `friend` = '".$tusername."'")) != 0){
	
	
mysql_query("DELETE FROM `friends` WHERE `username` = '".$username."' AND `friend` = '".$tusername."'");
	
	
mysql_query("DELETE FROM `friends` WHERE `username` = '".$tusername."' AND `friend` = '".$username."'");
	
	
echo 
$tusername.' is no longer a friend. T_T';
	
}
}