Recently, I've started working with cakePhp to handle ajax requests using prototype.
While my controller is returning the correct value, I'm struggling to figure out how to properly handle it when it comes back looking like this:
<?php echo $ajax->link("Update my ***** div", array( 'controller' => 'products', 'action' => 'test') , array("complete" => "update(request)") ); ?>
When I try alerting 'request' in my javascript update method, I only see the XMLHTTPRequest object and not the actual response.
I need to be able to work with the result in JavaScript once it's received, how can I achieve this?
I came across a solution on Stack Overflow, but it felt a bit messy - using the "update" option to update a hidden div with the result, then parsing that div with JavaScript once the call is completed. This approach would require one hidden div per ajax call (and I'll have multiple simultaneous calls), and I'm not keen on rendering something just to retrieve my ajax response.
Any guidance on this issue would be greatly appreciated.