Advertisement
Guest User

Untitled

a guest
Aug 26th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. if(http.readyState == 4 && http.status == 200) {
  2.  
  3. json=http.responseText;
  4. alert (json);
  5.  
  6.  
  7. }
  8.  
  9. alert (JSON.stringify(json));
  10.  
  11. onCreateLabel: function(label, node,tipo){
  12. label.id = node.id;
  13. label.innerHTML = node.name;
  14. label.onclick = function(){
  15.  
  16. var http = new XMLHttpRequest();
  17. var url = "inicio_pru.php";
  18. var JSONstr = JSON.stringify(json);
  19. var t_var = tipo;
  20. //alert (t_var);
  21. var params = "callFunction=anade_rama&json="+JSONstr+"&node_id="+node.id+"&tipo_var="+tipo_var;
  22. http.open("POST", url, true);
  23.  
  24. //Send the proper header information along with the request
  25. http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  26.  
  27.  
  28. http.onreadystatechange = function() {//Call a function when the state changes.
  29. if(http.readyState == 4 && http.status == 200) {
  30.  
  31. json=http.responseText;
  32. alert (json);
  33.  
  34.  
  35. }
  36. }
  37.  
  38. http.send(params);
  39. alert (JSON.stringify(json));
  40.  
  41. if($callFunction == "anade_rama") {
  42.  
  43.  
  44.  
  45.  
  46. $jsonString1=str_replace("$type","type",$jsonString);
  47. $jsonString2=str_replace("$color","color",$jsonString1);
  48.  
  49.  
  50.  
  51. $class = NodoArbolDHTML::fromJSONObject(json_decode($jsonString2));
  52. $arbol1=encontrar($class);
  53.  
  54.  
  55.  
  56. //Lo vuelvo a poner en formato json
  57. $arbol2=json_encode($arbol1);
  58.  
  59.  
  60.  
  61. //Aqui los remplaces
  62. $arbol3=str_replace("type","$type",$arbol2);
  63. $arbol=str_replace("color","$color",$arbol3);
  64.  
  65. echo($arbol);
  66. }
  67. else {
  68. $server = "localhost";
  69. $user = "adminconsulta";
  70. $pass = "Con,Adm6n";
  71. $bd = "Diagnosticos";
  72. $conexion = mysqli_connect($server, $user, $pass,$bd)
  73. or die("Ha sucedido un error inexperado en la conexion de la base de datos");
  74. $path_var='/'.$tipo_var.'/'.$tipo_var.'/'.$tipo_var;
  75. $sql = "SELECT DISTINCT ID,Label,Resultado,Tipo FROM Arbol WHERE Objeto='". $path_var. "'";
  76.  
  77. if(!$result = mysqli_query($conexion, $sql)) die();
  78.  
  79. while($row = mysqli_fetch_array($result))
  80.  
  81. {
  82.  
  83. $id_root=$row['ID'];
  84. $label_root=$row['Label'];
  85. $resultado_root=$row['Resultado'];
  86. $tipo_root=$row['Tipo'];
  87. }
  88.  
  89. //desconectamos la base de datos
  90. $close = mysqli_close($conexion)
  91. or die("Ha sucedido un error inexperado en la desconexion de la base de datos");
  92.  
  93.  
  94.  
  95. $children_root = buscaren_t_grande ($id_root);
  96.  
  97.  
  98.  
  99. $raiz = new NodoArbolDHTML($id_root,$label_root,$resultado_root,$tipo_root);
  100.  
  101. $root=recorrerArbol($children_root,$raiz);
  102.  
  103.  
  104.  
  105.  
  106.  
  107. $arbol1=json_encode($root);
  108. $arbol2=str_replace("type","$type",$arbol1);
  109. $arbol=str_replace("color","$color",$arbol2);
  110. return $arbol;
  111.  
  112.  
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement