Uso suse linux y firefox.
Mi programacion en php es modular con smarty, y quiero implementar xajax para ciertas cosas, tengo un modulo llamado galeria, el cual se estructura de la siguiente manera:
url: http://localhost/inmob/index.php?mod...ria&accion=zzz
index.php
Código PHP:
function principal(){
}
function xxx(){
}
function yyy(){
}
function zzz(){
}
switch($accion) {
case "xxx":
xxx();
break;
case "yyy":
yyy();
break;
case "zzz":
zzz();
break;
default:
principal();
break;
}
es decir:
Código PHP:
function principal(){
}
function xxx(){
}
function yyy(){
}
function zzz(){
require_once("includes/xajax/xajax.inc.php");
$xajax = new xajax();
$xajax->debugOn(); // Uncomment this line to turn debugging on
$xajax->statusMessagesOn();
$xajax->registerFunction("MuestraImagen");
$xajax->processRequests();
//$xajax->printJavascript();
$smarty -> assign('xajax_javascript',$xajax->getJavascript('includes/xajax/'));
}
function MuestraImagen($image)
{
require_once("includes/xajax/xajax.inc.php");
// do some stuff based on $arg like query data from a database and
// put it into a variable like $newContent
$newContent = "<A HREF=\"javascript:popUp('modulos/galeria/images/$image')\" TITLE=\"Ver a tamano completo\">";
$newContent .= '<img border=0 src="modulos/galeria/genthumbs.php?image='.$image.'&w=225" alt="'.$txtalt.'"><br>'.$descripcion.'<br><br>';
// FIN IMAGEN GRANDE
// Instantiate the xajaxResponse object
$objResponse = new xajaxResponse();
// add a command to the response to assign the innerHTML attribute of
// the element with id="SomeElementId" to whatever the new content is
$objResponse->addAssign("SomeElementId","innerHTML", $newContent);
ob_end_clean();
//return the xajaxResponse object
return $objResponse;
}
$accion=$_REQUEST['accion'];
switch($accion) {
case "xxx":
xxx();
break;
case "yyy":
yyy();
break;
case "zzz":
zzz();
break;
default:
principal();
break;
}
me arroja el siguiente mensaje:
Código:
gracias por cualquier ayuda. Error: the XML response that was returned from the server is invalid. Received: <html> <head> etc...
. Por ejemplo, si estás dentro de la función que vas a usar dentro de Ajax, no puedes tener ninguna salida de error en pantalla, porque todo lo que salga será interpretado como parte del xml, y esto hará que sea "mal formado". De la misma forma, me pasó que por un "espacio en blanco" al final de un clase que era invocada por el fuente de xajax (era la que hacía la abstracción de la base de datos), me daba el mismo mensaje de error, cuando nunca había tenido problemas antes con esa clase (y perdí horas para encontrarlo).
Este tema le ha gustado a 1 personas