gamesmstr Posted January 15, 2009 Share Posted January 15, 2009 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? Quote Link to comment Share on other sites More sharing options...
gamesmstr Posted January 15, 2009 Author Share Posted January 15, 2009 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); } Quote Link to comment Share on other sites More sharing options...
gamesmstr Posted January 16, 2009 Author Share Posted January 16, 2009 Anybody? Please. This is driving me nuts! Quote Link to comment Share on other sites More sharing options...
mugs Posted January 16, 2009 Share Posted January 16, 2009 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.. Quote Link to comment Share on other sites More sharing options...
dawsba Posted January 17, 2009 Share Posted January 17, 2009 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; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.