How can i call a JS function when the ajax request is completed
I'm Using Js helper and RequestHandler Component
This is my view file
<?php echo $this->Js->submit('Create User', array(
'before'=>$this->Js->get('#loading')->effect('fadeIn'),
'success'=>$this->Js->get('#loading')->effect('fadeOut'),
'update'=>'#success',
));
?>
i'm getting a loading message and success message...
I want to call a JS function when the ajax request is done/completed, so that i can close the User registration DIV
i solved it...there is a method in Js Helper called complete and we can call JS function
<?php echo $this->Js->submit('Create User', array(
'before'=>$this->Js->get('#loading')->effect('fadeIn'),
'success'=>$this->Js->get('#loading')->effect('fadeOut'),
'update'=>'#success',
'complete' => 'self.setInterval("test()",2000);'
));
test() will be called after ajax request is completed.
Related
I am using the below code in my Controller file to generate full site URL
$this->Url->build(['controller' => 'home', 'action' => 'index'], true);.
But I am getting a "Call to a member function build() on boolean" error. The reason why I am not using
Router::URL(['controller' => 'home', 'action' => 'index']);
is I don't want a relative URL. Can't I use Url builder in the controller?
I think, the main reason of your Error is wrong name of Controller.
First,Name Conventions says
"Controller class names are plural, PascalCased, and end in Controller. UsersController and ArticleCategoriesController are both examples of conventional controller names."
so your file name must be like HomesController.php. Next the Class name should be like this HomesController.
Secondly, for CakePHP character size matters. If you want build URL to your controller you have to do like this
$this->Url->build(['controller' => 'Home', 'action' => 'index'], true);
Where controller name should be capitalize.
More about building URL in CakePHP
I have list of appointments in my database and I want to add a delete button for each appointment so when the delete button is licked the appointment gets deleted.
HTML Code
' <td>\n' +
' <a >Delete</a> </td>\n'+
' </tr>\n' +
this is the delete button
Route.php
$api->delete('appointments/del', 'AppointmentsController#delete_appointment');
I have added this route in laravel.
AppointmentsController.php
public function delete_appointment(){
console.log("delete");
}
now I am unable to call this function on the button click.
I have tried ng-click and href ethod too, but no success.
you can not directly call laravel controller function from angular. you will have to make an http call from your angular application using the url (route) of your laravel controller function.
I am using CakePHP 2.6.9.
I want to do following:
www.example.com/detail/10 should refer to controller => frontends and action => detail
www.example.com/admins/login should refer to controller => admins and action => login
I edited routes.php as follows:
Router::connect('/:action/*',
array('controller' => 'frontends', 'action' =>'detail'));
But when I try www.example.com/admins/login it shows the following error:
The action admins is not defined in controller FrontendsController
It proves that www.example.com/admins/login refers to
Router::connect('/:action/*',
array('controller' => 'frontends', 'action' =>'detail'));
Routing. I want
Router::connect('/:action/*',
array('controller' => 'frontends', 'action' =>'detail'));
will be only for controller => frontends and action=>detail, rest of url will work as default. Any idea?
this will do want you want.
Router::connect('/detail/*', array('controller' => 'Frontends', 'action' =>'detail'));
Mostly cakephp urls are like /controller/action/id. Your template of the route /:action/* tells that you are not using controller names in urls instead you are using only action names like /detail/id and /admins/id, and all actions are in Frontends controller. You can see from the error message that it tried to find admins action in Frontends conntroller.
I am learning cake php . I made plugin with folder name Map , every thing goes fine . but when i call other function then index() in MapController class . it gives error
Map.functionName could not be found.
but i made that function in MapController class .
url -- http://localhost/rootfolder/map/functionName
Please tell whats the problem. Can we not able to make other function than index() in plugin ?
Thanks in advance.
For plugins, the default URL path is /:plugin/:controller/:action, so you'll probably need to access /map/map/action. This can be re-written with routes like so:
Router::connect('/something/', array('plugin' => 'map', 'controller' => 'map', 'action' => 'someACtion'));
I want to make a login system, with the 'forgot password?' , this is the only example that i found..forgotten-password
but i have a problem with my auth permission... i put the link 'forgot password?' in my view login.ctp when I click on the link not allow me to redirect to /user/forgot.ctp and send me a message from my function beforeFilter() on file app_controller.php
this is my link in the login.ctp
<?php echo $html->link('¿forgot password?', array('controller' => 'users', 'action' =>
'forgot')); ?></p>
when I login it works, but when I'm not logged in doesnt work and send me the message error
which could be the problem?
I haven't taken a look at the tutorial, but have you tried the beforefilter method in users_controller?
function beforeFilter() {
parent::beforeFilter();
$this->Auth->allow('forgot');
}