code_junkie

javascript not working, no errors

Nov 12th, 2011
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 KB | None | 0 0
  1. var xmlHttp
  2. var layername
  3. var url
  4.  
  5. function update(layer, part, pk, query) {
  6. alert ("update");
  7. if (part=="1") {
  8. alert ("part 1");
  9. url = "get_auction.php?cmd=GetAuctionData&pk="+pk+"&sid="+Math.random()
  10. } else if (part=="2") {
  11. alert ("part 2");
  12. url = "get_records.php?cmd=GetRecordSet&query="+query+"&sid="+Math.random()
  13. }
  14. xmlHttp=GetXmlHttpObject()
  15. if(xmlHttp==null) {
  16. alert("Your browser is not supported?")
  17. }
  18. xmlHttp.onreadystatechange = function() {
  19. if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
  20. document.getElementById(layer).innerHTML=xmlHttp.responseText
  21. } else if (xmlHttp.readyState==1 || xmlHttp.readyState=="loading") {
  22. document.getElementById(layer).innerHTML="loading"
  23. }
  24. };
  25. xmlHttp.open("GET",url,true)
  26. xmlHttp.send(null)
  27. }
  28.  
  29. function GetXmlHttpObject() {
  30. var xmlHttp=null;
  31. try {
  32. xmlHttp = new XMLHttpRequest();
  33. } catch (e) {
  34. try {
  35. xmlHttp =new ActiveXObject("Microsoft.XMLHTTP");
  36. } catch (e) {}
  37. }
  38. return xmlHttp;
  39. }
  40.  
  41. function makewindows() {
  42. child1 = window.open ("about:blank");
  43. child1.document.write(<?php echo htmlspecialchars(json_encode($row2["ARTICLE_DESC"]), ENT_QUOTES); ?>));
  44. child1.document.close();
  45. }
  46.  
  47. echo "<li><a href='#' onclick=update('Layer3','2','0','hello')'>Link 1</a></li>" .
  48.  
  49. <li><a href='#' onclick='update('Layer3','2','0','hello')'>Link 1</a></li>
  50.  
  51. echo '<li><a href="#" onclick="update('Layer3','2','0','hello')">Link 1</a></li>' . "n";
  52.  
  53. function update(layer, url) {
  54. var xmlHttp=GetXmlHttpObject(); //you have this defined elsewhere
  55.  
  56. if(xmlHttp==null) {
  57. alert("Your browser is not supported?");
  58. }
  59.  
  60. xmlHttp.onreadystatechange = function() {
  61. if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
  62. document.getElementById(layer).innerHTML=xmlHttp.responseText;
  63. } else if (xmlHttp.readyState==1 || xmlHttp.readyState=="loading") {
  64. document.getElementById(layer).innerHTML="loading";
  65. }
  66.  
  67. //etc
  68. }
  69.  
  70. xmlHttp.open("GET",url,true);
  71. xmlHttp.send(null);
  72. }
  73.  
  74.  
  75. function updateByPk(layer, pk) {
  76. url = "get_auction.php?cmd=GetAuctionData&pk="+pk+"&sid="+Math.random();
  77. update(layer, url);
  78. }
  79.  
  80.  
  81. function updateByQuery(layer, query) {
  82. url = "get_records.php?cmd=GetRecordSet&query="+query+"&sid="+Math.random();
  83. update(layer, url);
  84. }
  85.  
  86. updateByPk('id_of_div', 2);
  87.  
  88. updateByQuery('id_of_div2', 'query');
  89.  
  90. <a href="#" onclick="updateByQuery('Layer3', 'hello');">Link 1</a>
  91.  
  92. <?php echo '<a href="#" onclick="updateByQuery('Layer3', ' . json_encode($query) . ');">Link 1</a>';
  93.  
  94. function myFunction(var1, var2, var3, var4){
  95.  
  96. myFunction('test1','test2');
  97.  
  98. if(null != var3){
  99.  
  100. child1.document.write(<?php echo htmlspecialchars(json_encode($row2["ARTICLE_DESC"]), ENT_QUOTES); ?>));
  101.  
  102. onclick=update('Layer3','2','0','hello')'>Link 1
  103.  
  104. onclick="update('Layer3','2','0','hello')">Link 1
  105.  
  106. onclick='update('Layer3','2','0','hello')'>Link 1
  107.  
  108. function update(layer, part, pk, query) {
  109. alert ("update");
  110. if (part=="1") {
  111. alert ("part 1");
  112. url = "get_auction.php?cmd=GetAuctionData&pk="+pk+"&sid="+Math.random()
  113. } else if (part=="2") {
  114. alert ("part 2");
  115. url = "get_records.php?cmd=GetRecordSet&query="+query+"&sid="+Math.random()
  116. }
  117. // and so on...
  118. }
Add Comment
Please, Sign In to add comment