Jump to content

Interesting problem....


gamesmstr

Recommended Posts

I run a text based mmorpg that uses php.  I have several sections I have ajaxed to smooth things out and to prevent cheating using autorefreshers.  One of these things is a dungeon.  I am having several users complain that when they move about it is "jumpy" where previously they have had no problems.  Sometimes the screens don't refresh in order and and it is causing problems.  Is this a problem that is common?  Is there something I can do or tell my players to do to fix it?

Link to comment
Share on other sites

After much research, I have discovered the solution and a new problem.  I need to make the ajax submissions Synchronous.  The problem is that Firefox crashes with a synchronous submission due to the absence of readystatechange on a synchronous call.  Using the following code, how can I code it so that Firefox will accept it?

 

	function createXMLHttpRequest() {
	if (typeof XMLHttpRequest != 'undefined') { 
		return new XMLHttpRequest(); 
	} 
	try { 
		return new ActiveXObject("Msxml2.XMLHTTP"); 
	} catch (e) {
			try { 
				return new ActiveXObject("Microsoft.XMLHTTP"); 
			} catch (e) {}
	}
	return false; 
}

function playermove(action) {
	var xmlHttp11_out = createXMLHttpRequest();

	params = "action=" + action;

	xmlHttp11_out.open("POST","ajax/outlands-move.php", false);
	xmlHttp11_out.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	xmlHttp11_out.onreadystatechange = function() {
		if(xmlHttp11_out.readyState == 4 && xmlHttp11_out.status == 200) {
			document.getElementById("outlandsbox").innerHTML = xmlHttp11_out.responseText;
			refresh_stats();				
		}
	}
	xmlHttp11_out.send(params);
}

Link to comment
Share on other sites

hello!

 

well i use mozilla firefox extensively bt i hv never come across such a problem.. synchronous requests work fine in my code.. the problem must be sumthin else, please chk it out once again..

if it still doesnt work, then plz explain ur prob in a lil bit more detailed manner..

Link to comment
Share on other sites

wow theres alot of ajax stuff today works all browser supporting JS

function createRequestObject() { 
  var ro; 
  var browser = navigator.appName; 
  if(browser == "Microsoft Internet Explorer"){ 
    ro = new ActiveXObject("Microsoft.XMLHTTP"); 
  }else{ 
    ro = new XMLHttpRequest(); 
  } 
  return ro; 
} 
var http = createRequestObject(); 
var returnDiv 
function sndReq(divRet,file) { 
  var date = new Date();
  var timestamp = date.getTime();
  returnDiv = divRet; 
  http.open('get', file+'&time='+timestamp); 
  http.onreadystatechange = handleResponse; 
  http.send(null); 
} 
function handleResponse() { 
  if(http.readyState == 4){ 
    var response = http.responseText; 
    document.getElementById(returnDiv).innerHTML = response; 
  } 
}
function resetdefault(a,b)
{
  document.getElementById(a).innerHTML = document.getElementById(b).innerHTML;
}

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.