Hey,
I’m having a problem using Ajax with my ColdBox app. I am following the directions located at the following url:
http://ortus.svnrepository.com/coldbox/trac.cgi/wiki/cbAjaxHints
In my setup I have a handler named “newsletterSubscriber” and a method named “doSignUp” which takes an email address submitted with Ajax and inserts it into the database. Simple enough.
Here is my Ajax script (using Prototype):
Event.observe(window,‘load’,init,false);
function init(){
Event.observe(‘newsletter’,‘submit’,persistAddress);
}
function persistAddress(e){
$(‘response’).style.visibility=‘visible’;
$(‘response’).innerHTML=‘Adding email address…’;
var pars = ‘email=’ + escape($F(‘email’));
var myAjax = new Ajax.Updater(‘response’,'NewsletterSubscriber.doSignUp ', {method: ‘get’, parameters: pars});
Event.stop(e);
}
The init() function is an event handler that is fired when the newsletter form is submitted. The persistAddress() function sends the email address to " NewsletterSubscriber.doSignUp" which should insert the email and return a string confirming success or failure.
Unfortunately, when the form is submitted I get an error stating that “t he requested URL /NewsletterSubscriber.doSignUp was not found on this server.”
What am I doing wrong? I’m sure it must have to do with this line:
var myAjax = new Ajax.Updater(‘response’,‘NewsletterSubscriber.doSignUp’, {method: ‘get’, parameters: pars});
Am I supposed to put something other than “NewsletterSubscriber.doSignUp” for the url to submit to?
Thanks for your help,
Aaron