[Catalyst] Jemplate and AJAX woes... [Bump -anyone??]

kakimoto at tpg.com.au kakimoto at tpg.com.au
Thu Aug 14 06:57:29 BST 2008


I have managed to get Jon Rockway's  AddressBook application (from
chapter 7 of the book) to work (ie i managed to log in as I put in the
SQLs for User,UserRole and Role tables).


I tried to edit an address and

1) it does not work (ie. the webpage did not change and present a form
for edit)
2) got the extract below from "Error console" of firefox.

Error: [Exception... "Component returned failure code: 0x80040111
(NS_ERROR_NOT_AVAILABLE) [nsIXMLHttpRequest.status]"  nsresult:
"0x80040111 (NS_ERROR_NOT_AVAILABLE)"  location: "JS frame ::
http://gozila-underground.com:3000/static/Jemplate.js :: anonymous ::
line 791"  data: no]
Source File: http://gozila-underground.com:3000/static/Jemplate.js
Line: 791





 764
//------------------------------------------------------------------------------
 765 // Ajax support
 766
//------------------------------------------------------------------------------
 767 if (! this.Ajax) Ajax = {};
 768
 769 Ajax.get = function(url, callback) {
 770     var req = new XMLHttpRequest();
 771     req.open('GET', url, Boolean(callback));
 772     req.setRequestHeader('Accept', 'text/x-json; q=1.0');
 773     return Ajax._send(req, null, callback);
 774 }
 775
 776 Ajax.post = function(url, data, callback) {
 777     var req = new XMLHttpRequest();
 778     req.open('POST', url, Boolean(callback));
 779     req.setRequestHeader('Accept', 'text/x-json; q=1.0');
 780     req.setRequestHeader(
 781         'Content-Type',
 782         'application/x-www-form-urlencoded'
 783     );
 784     return Ajax._send(req, data, callback);
 785 }
 786
 787 Ajax._send = function(req, data, callback) {
 788     if (callback) {
 789         req.onreadystatechange = function() {
 790             if (req.readyState == 4) {
 791                 if(req.status == 200)
 792                     callback(req.responseText);
 793             }
 794         };
 795     }
 796     req.send(data);
 797     if (!callback) {
 798         if (req.status != 200)
 799             throw('Request for "' + url +
 800                   '" failed with status: ' + req.status);
 801         return req.responseText;
 802     }
 803 }
 804



I think it would be good if more tutorials were to be given for Jemplate.
 Otherwise, all the fancy new framework and shiny new developments would
not pick up WITHOUT substantial DOCUMENTATION cause not many people
would have the time to open up source codes to figure out how they work.


K. akimoto



More information about the Catalyst mailing list