AJAX - pasar datos xml con ajax a php

 
Vista:

pasar datos xml con ajax a php

Publicado por juanma (1 intervención) el 20/01/2014 14:11:42
Hola a todos!
Estoy intentando pasar datos xml a traves de ajax a php del siguiente modo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$.ajax({
    					type     : "POST",
    					url      : "/php/uploadkml.php",
    					data     : { xml: output },
    					dataType : "xml",
    					success  : function(datos){
    						document.getElementById('dataOut').innerHTML = datos;
        				alert("Success");
    					},
    					error    : function(datos) {
    						if (datos){
               				datakml = eval(datos);
    						document.getElementById('dataOut').innerHTML = datakml;
    						}
        				alert("Failed");
    					}
					});

y los recibo del siguiente modo,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php
include("conex.phtml");
$link=Conectarse();
//collect data send as XML   
//$xml = file_get_contents('php://input'); 
$xml=$_POST['xml'];
//open a file handler with read and write permission  
$fh = fopen('userinfo.kml', 'r+');
//writing XML string to the new file  
fwrite($fh, $xml);
//closing the file handler  
fclose($fh);
echo '' . json_encode($xml) . '';
 
mysql_close($link);
exit();
?>

que estoy haciendo mal?
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de xve
Val: 90
Oro
Ha mantenido su posición en AJAX (en relación al último mes)
Gráfica de AJAX

pasar datos xml con ajax a php

Publicado por xve (222 intervenciones) el 20/01/2014 19:38:21
Hola Juanma, parece que esta todo bien... que error o problema tienes?
Que valor tiene la variable output?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar