Ajax request with Routing

Permalink 1 user found helpful
I am developing a block . i am trying to call Ajax functionality with below code

public function on_start() {
      parent::on_start(); 
      Route::register( '/my/ajax/load_data', 'Concrete\Package\*packageName*\Block\*blockName*\Controller::load_data' );
   }
   public function load_data() {
      echo "hasan test";
   }


url i am browsing
index.php/my/ajax/load_data

but code not working. anyone help me ?

Thanks

 
A3020 replied on at Permalink Reply
A3020
Try putting the Route::register in the package controller on_start.
mesuva replied on at Permalink Reply
mesuva
SNAP!
hasan123 replied on at Permalink Reply
Thanks for the reply
I moved it to package
now got following error

"Call to undefined method Concrete\Package\*\Block\*\Controller::getViewObject()"
A3020 replied on at Permalink Best Answer Reply
A3020
I *think* that error is not related to the custom route you've just set up. Put an exit() in the load_data function to verify that the route works.
hasan123 replied on at Permalink Reply
Thanks.
You are great...
Its working now
TheRealSean replied on at Permalink Reply
TheRealSean
What did you do to get this working?
TheRealSean replied on at Permalink Reply
TheRealSean
Ok I think I've got it.

The route itself is actually working, in my case there are a number of methods that have changed from v7 to v8 and as such are causing errors in the ajax return.
mesuva replied on at Permalink Reply
mesuva
The on_start() method needs to be in a package controller. This looks like you've got this in the block's controller.