hey guys!
I finally have a working ajax script, it's from a tutorial and i have altered it to my liking.I have some questions regarding it. Here's the code.
So this outputs a table inside a div in my page that i generate with navscanner.phpCode:<script type="text/javascript"> //scanner AJAX function Ajax() { var scanner; try { scanner=new XMLHttpRequest();// Firefox, Opera 8.0+, Safari } catch (e) { try { scanner=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer } catch (e) { try { scanner=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser has no ajax support!"); return false; } } } scanner.onreadystatechange=function() { if(scanner.readyState==4) { document.getElementById('scanner').innerHTML=scanner.responseText; setTimeout('Ajax()',2000); } } scanner.open("GET","navscanner.php",true); scanner.send(null); } window.onload=function() { setTimeout('Ajax()',2000); } </script>
Now i have a lot more div's to be filled like this. And i'm kinda stuck to where to put the new code.
1) Do i need to make the browser check each time i do a ajax request?
2)If i need more divs to refresh each 2 second like above code can i use the above code to make that happen or do i need a totally new function?
3)same question as 3 but for div's that need to get loaded on start and when a player clicks something. Can i put all this code inside the Ajax function or do i need sepperate functions for each?


Reply With Quote
Bookmarks