1 (edited by Damien2k9 2013-04-10 12:17:36 AM)

Topic: ResponseReceived: Invalid response XML: The response contains an unexp

xajax ERROR: Response Received: Invalid response XML: The response contains an unexpected tag or text

Hi dudes,

I'm having a problem with the response of Xajax. Once active the button that calls the php function via xajax the browser not stop read a page, is always in read mode and debug respond me the following error.

xajax debug output
Tue Apr 09 2013 19:57:54 GMT-0300 (Hora oficial do Brasil)

ERROR: ResponseReceived: Invalid response XML: The response contains an unexpected tag or text: {data}.

Tue Apr 09 2013 19:57:54 GMT-0300 (Hora oficial do Brasil)

RECEIVED [status: 200, size: 379 bytes, time: 245ms]:
UPDATE Apoio SET Active = '1' WHERE ID = '1'<?xml version="1.0" encoding="utf-8" ?>
<xjx>
<cmd cmd="as" id="activarApoio1" prop="innerHTML"><![CDATA[S<a href="#" onClick="xajax_activarApoio('1','1')"><img src=""http://atletasdofuturo.com.br:80/new/admin/templates/images/Green-Ball-icon.png" width="20" height="20" style="cursor:pointer;" border="0" alt="" /></a>]]></cmd>
</xjx>

Tue Apr 09 2013 19:57:53 GMT-0300 (Hora oficial do Brasil)

SENT [64 bytes]

Tue Apr 09 2013 19:57:53 GMT-0300 (Hora oficial do Brasil)

SENDING REQUEST

Tue Apr 09 2013 19:57:53 GMT-0300 (Hora oficial do Brasil)

CALLING:
xjxfun: activarApoio
URI:
http://atletasdofuturo.com.br/new/admin … hp?a=apoio

Tue Apr 09 2013 19:57:53 GMT-0300 (Hora oficial do Brasil)

POST: xjxfun=activarApoio
&xjxr=1365548273797
&xjxargs[]=S0
&xjxargs[]=S1

Tue Apr 09 2013 19:57:53 GMT-0300 (Hora oficial do Brasil)

INITIALIZING REQUEST OBJECT

Tue Apr 09 2013 19:57:53 GMT-0300 (Hora oficial do Brasil)

PREPARING REQUEST

Tue Apr 09 2013 19:57:53 GMT-0300 (Hora oficial do Brasil)

PROCESSING PARAMETERS [2]

Tue Apr 09 2013 19:57:53 GMT-0300 (Hora oficial do Brasil)

INITIALIZING REQUEST

Tue Apr 09 2013 19:57:53 GMT-0300 (Hora oficial do Brasil)

STARTING XAJAX REQUEST

Already removed all spaces on the pages php <?php?>

Below are the functions that xajax calls

function activarApoio($value, $ID) {    
    $objResponse = new  xajaxResponse();
    $error = "";
    if ($value == "1") {
        $xValue = 0;
    } else{
        $xValue = 1;
    }    
    if ($ID == "") {
        $error = 1;
        $objResponse->alert("Nenhum ID foi recebido!");
    }    
    if (!$error) {        
        $objMySqlX = new MySql;        // Cria o objecto da class
        $query = "UPDATE Apoio SET Active = '$xValue' WHERE ID = '$ID'";
        $objMySqlX->query($query);    // Executa a consulta
        echo $query;
        if($xValue == "1") {
            $img = '<img src=""{$smarty.const.IMG_URL}Green-Ball-icon.png" width="20" height="20" style="cursor:pointer;" border="0" alt="" />';
        } else {
            $img = '<img src=""{$smarty.const.IMG_URL}Red-Ball-icon.png" width="20" height="20" style="cursor:pointer;" border="0" alt="" />';
        }        
        $div = '<a href="#" onClick="xajax_activarApoio(';
        $div .= "'$xValue','$ID')";
        $div .= '">';
        $div .= "$img";
        $div .= "</a>";
        $objResponse->assign("activarApoio$ID", "innerHTML", $div);
    }
        return $objResponse;
}
$objXajax->registerFunction("activarApoio");
<div id="activarApoio{$xID[i]}" style="text-align:center;"><a href="#" onClick="xajax_activarApoio('{$xActive[i]}','{$xID[i]}')">{if $xActive[i] == '0'}<img src="{$smarty.const.IMG_URL}Red-Ball-icon.png" width="20" height="20" style="cursor:pointer;" border="0" alt="Alterar o estado" />{else}<img src="{$smarty.const.IMG_URL}Green-Ball-icon.png" width="20" height="20" style="cursor:pointer;" border="0" alt="Alterar o estado" />{/if}</a></div>

Re: ResponseReceived: Invalid response XML: The response contains an unexp

Hi,

This code:

if (!$error) {        
        $objMySqlX = new MySql;        // Cria o objecto da class
        $query = "UPDATE Apoio SET Active = '$xValue' WHERE ID = '$ID'";
        $objMySqlX->query($query);    // Executa a consulta
        echo $query;

contains an echo statement (echo $query). This messes up the xajax client side response handler.

Never echo, print, print_r, var_dump or anything else that produces output when processing an xaja request...

UPDATE Apoio SET Active = '1' WHERE ID = '1' appears before the xml tag in the response. Remove the echo and see what happens.

Ed

If you ever stop learning you may as well dig a hole, crawl in and pull the top over yourself.

Re: ResponseReceived: Invalid response XML: The response contains an unexp

Hi adrobinson

Thanks dude, now working fine....to many code to ready and this line pass....wow

thanks again