Hi guys,
I have an app that I wrote using Cake and I have a decent
understanding of the Cake principles and techniques. However, I
started to make some of my actions ajax driven and still haven't been
able to successfully complete the process. I red through tons of
posts and tried to glue together bits and pieces of some people who
don't use the built in spriptaculous and use a different library (ie.
jquery) but haven't had much luck making it work. Below is my
scenario:
JavaScript code (YUI):
// Make the call to the server for JSON data
YAHOO.util.Connect.asyncRequest('POST','<?php echo $html->url('/
organization/join/'.$organization['id']); ?>', callbacks);
// My callbacks
var callbacks = {
success : function (o) {
// Process the JSON data returned from the server
var messages = [];
try {
messages = YAHOO.lang.JSON.parse(o.responseText);
}
catch (x) {
alert("JSON Parse failed!");
return;
}
// The returned data was parsed into an array of
objects.
// Do whatever here
},
failure : function (o) {
if (!YAHOO.util.Connect.isCallInProgress(o)) {
alert("Async call failed!");
}
},
timeout : 3000
}
Questions:
1 - What should I have in my beforeFilter() for this controller?
2 - How do I get the action to return a Json only?
3 - Do I have to add any .ctp file or modify routes.php?
I appreciate if someone could provide me with all the things needed to
get a json object back from an AJAX request.
PS: I am using 1.2 beta, thanks!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---