I am trying to create an ajax function in my coldbox application,
following the Task Manager demo, but it doesnt seem to be functioning
Initially I am not sure whether I can call the function from my
external JS file? Because in the example the JS is hardcoded on the
page and uses cfsavecontent..
Regardless I have the following code in my external js file
// Hardcoded variables just as an example..
var sTitle = ‘hello’;
var iTaskListID = 1;
// Processing goes here
And my tasks/save handler is based on the one in the Task Manager Demo
var rc = event.getCollection();
rc.task = taskService.getTask(event.getValue("taskID",""));
This doesnt appear to be working for me, could anyone point me in the
I don’t see anything in your handler event that is actually returning any kind of data. Your JS function appears to be expecting JSON, but in the handler the last executable line simply calls a method on a service layer object. Unless I’m missing something, I think the final piece of the puzzle you’re missing to bridge this gap is probably the event.RenderData() method, which is used almost exclusively for the purpose of creating handler methods intended to be consumed by remote/ajax calls.
Since the method you’re calling is simply a save method, I’m not sure what data you’d be returning, except perhaps a status flag indicating success or failure. But, whatEVER you wanted returned, you’d do it with something like the following in your handler method:
status = taskService.save(rc.task);
Thanks for the response..
Looks like im going about this the wrong way...
For the moment I dont really need to return any data, im just looking
to save info into the database..
However when I click on my link that calls the "save task" function it
doesnt work.....the post shows an error in firebug...it has no
specific details, it just flags it up in red.
I usually post directly to the method itself, like so
var sTitle = 'hello';
var iTaskListID = 1;
Which works, but I dont want to bypass the coldbox framework to
achieve what im doing.
I have tried add renderData, but its still bringing up an error in