DojoX Django Template Language Example with Data from PHP/JSON

This is a simple example how you would use DojoX Django Template Language component filled with data from a JSON GET Response:

<script type="text/javascript" src="/development/dojo-release-1.1.1/dojo/dojo.js" djConfig="parseOnLoad:true, isDebug:true"></script>

<script language="javascript" type="text/javascript"><!--
    dojo.xhrGet({url: "dojotest.php", handleAs: "json", handle: function(data,ioArgs){
        if(typeof data == "error"){
        } else {
            dojo.query("#test").dtl("I am eating {{food.fruit}} and {{food.meat}}", data);


    header('Content-type: text/json');
    $food = array('food' => array('fruit' => 'apple', 'meat' => 'chicken'));
    echo json_encode($food);
More about: Javascript / Dojo

Sign up for my newsletter to get notified when I post new content on this blog and with the occasional exclusive content only for subscribers.

By clicking on the Subscribe button I am giving my consent for Benjamin Eberlei to hold my name and email address for the purposes of contacting me with a newsletter on the topics of this blog. You can unsubscribe with one click at any time and withdraw your consent. No spam. I will never share your e-mail address. Privacy Policy