Advertisement
Guest User

Untitled

a guest
Aug 27th, 2015
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. function LoadMobs(dung){
  2.  
  3. var xhr;
  4. if (window.XMLHttpRequest) {
  5. xhr = new XMLHttpRequest();
  6. } else if (window.ActiveXObject) {
  7. xhr = new ActiveXObject("Msxml2.XMLHTTP");
  8. } else {
  9. throw new Error("Ajax is not supported by this browser");
  10. }
  11.  
  12. xhr.onreadystatechange = function () {
  13. if (xhr.readyState === 4) {
  14. if (xhr.status == 200 && xhr.status < 300) {
  15. // get mobs from PHP
  16. setTempMobs(JSON.parse(xhr.responseText));
  17. alert(tmpMs[0].NAME);
  18. }
  19. }
  20. }
  21.  
  22. xhr.open('POST', 'loadmobs.php');
  23. xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  24. xhr.send("dung=" + dung);
  25.  
  26. }
  27.  
  28. function setTempMobs(mss){
  29. tmpMs = mss;
  30. }
  31.  
  32. LoadMobs(currDungBgIndex);
  33. alert(tmpMs[0].NAME);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement