开发者

XML cannot be the whole program

XML cannot be the whole program - anyone else seen this firebug error? happening when receiving remote data (json, as it were) via ajax.

If data type changed json to html, working fine.

This is my actual code in php:

I reloaded the page, once session has been expired.

if($action->getRequest()->isXmlHttpRequest())
{           
  $action->getResponse()->setContent("<script>window.location.reload();</script>");      
  $action->getResponse()->send();      
}

firebug displ开发者_StackOverfloways the following error:

XML cannot be the whole program [Break on this error] window.location.reload();


Are you passing it the correct data format from the Ajax call? The error says it's something to do with XML, but you said you had it set to JSON, not XML.


You're sending the string "<script>window.location.reload();</script>" which does not contain JSON/JS but HTML. So the client tries to interpret the string as JSON/JS but notices that the whole script is just a single XML literal.


You cannot use the tags while loading in this way. Try to load the Javascript statements without using the tags in the loaded file. e.g:

This code generates the same error, if I load it dynamically.

<?php
    echo "<script type='text/javascript'>alert('Hi');</script>";
?>

This code doesn't generate any error and instead works like a charm:

<?php
    echo "alert('Hi');";
?>

This should help you out.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜