I resolved this by using MochiKit's evalJSONRequest instead of using
JS eval on request.response_text.  Here's sample code for a MochiKit
JS to Django AJAX function:

    selectEntity : function (entity)
    {
        try
        {
            var url = '/' + ['visionary', this.model.url ?
this.model.url : this.cn, 'select', '?xhr'].join('/');
            var q = [this.app, this.cn, 'id'].join('_') + '=' +
entity.pk;
            var r = {method: 'POST',
                     mimeType: 'application/javascript',
                     headers: [['Content-Type', 'application/x-www-
form-urlencoded']],
                     sendContent: q};
            var d = MochiKit.Async.doXHR(url, r);
            d.addCallback(MochiKit.Base.bind(function (result) {
                    try
                    {
                        MochiKit.Logging.log('Callback Request: ' +
result);
                        var r =
MochiKit.Async.evalJSONRequest(result);
                        MochiKit.Logging.log('Callback Request JSON: '
+ r.toJSONString());
                        var response = r;
                        if(typeof(r) != 'undefined')
                        {
                            var consoleMessage =
r.initial_console_message;
 
MochiKit.Base.map(MochiKit.Base.bind(function (index) {
                                consoleMessage += "<br>   " + index +
": " + r[index];
                                var rowId = [this.app, this.cn,
r[index], 'row'].join('_');
 
this.setRowHighlight(MochiKit.DOM.getElement(rowId),
                                                     index ==
'newId' ? true : false);
                            }, this), ['newId', 'oldId']);
                            this.updateConsole(consoleMessage);
                        }
                        else
                        {
                            throw new Error('Failed to resolve XHR
Response. Result: ' + result);
                        }
                    }
                    catch(e)
                    {
                        MochiKit.Logging.logError('selectEntity
Callback fn ' + e);
                    }
                }, this));
            d.addErrback(MochiKit.Base.bind(function (result) {
                    MochiKit.Logging.log('Callback Request: ' +
result);
                }, this));
        }
        catch(e)
        {
            MochiKit.Logging.logError('selectEntity(' + entity + ') '
+ e);
        }
        return false;
    }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to