Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(http.readyState == 4 && http.status == 200) {
- json=http.responseText;
- alert (json);
- }
- alert (JSON.stringify(json));
- onCreateLabel: function(label, node,tipo){
- label.id = node.id;
- label.innerHTML = node.name;
- label.onclick = function(){
- var http = new XMLHttpRequest();
- var url = "inicio_pru.php";
- var JSONstr = JSON.stringify(json);
- var t_var = tipo;
- //alert (t_var);
- var params = "callFunction=anade_rama&json="+JSONstr+"&node_id="+node.id+"&tipo_var="+tipo_var;
- http.open("POST", url, true);
- //Send the proper header information along with the request
- http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
- http.onreadystatechange = function() {//Call a function when the state changes.
- if(http.readyState == 4 && http.status == 200) {
- json=http.responseText;
- alert (json);
- }
- }
- http.send(params);
- alert (JSON.stringify(json));
- if($callFunction == "anade_rama") {
- $jsonString1=str_replace("$type","type",$jsonString);
- $jsonString2=str_replace("$color","color",$jsonString1);
- $class = NodoArbolDHTML::fromJSONObject(json_decode($jsonString2));
- $arbol1=encontrar($class);
- //Lo vuelvo a poner en formato json
- $arbol2=json_encode($arbol1);
- //Aqui los remplaces
- $arbol3=str_replace("type","$type",$arbol2);
- $arbol=str_replace("color","$color",$arbol3);
- echo($arbol);
- }
- else {
- $server = "localhost";
- $user = "adminconsulta";
- $pass = "Con,Adm6n";
- $bd = "Diagnosticos";
- $conexion = mysqli_connect($server, $user, $pass,$bd)
- or die("Ha sucedido un error inexperado en la conexion de la base de datos");
- $path_var='/'.$tipo_var.'/'.$tipo_var.'/'.$tipo_var;
- $sql = "SELECT DISTINCT ID,Label,Resultado,Tipo FROM Arbol WHERE Objeto='". $path_var. "'";
- if(!$result = mysqli_query($conexion, $sql)) die();
- while($row = mysqli_fetch_array($result))
- {
- $id_root=$row['ID'];
- $label_root=$row['Label'];
- $resultado_root=$row['Resultado'];
- $tipo_root=$row['Tipo'];
- }
- //desconectamos la base de datos
- $close = mysqli_close($conexion)
- or die("Ha sucedido un error inexperado en la desconexion de la base de datos");
- $children_root = buscaren_t_grande ($id_root);
- $raiz = new NodoArbolDHTML($id_root,$label_root,$resultado_root,$tipo_root);
- $root=recorrerArbol($children_root,$raiz);
- $arbol1=json_encode($root);
- $arbol2=str_replace("type","$type",$arbol1);
- $arbol=str_replace("color","$color",$arbol2);
- return $arbol;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement