Jump to content

Javascript XMLHttpRequest cache help


Xenos360

Recommended Posts

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

function toggleFriend(ruser, eleId){
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){
		q = 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" + queryString, true);
ajaxRequest.send(null);
}

 

 

And the .php file

// 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';
}
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.