Joomla Ajax Request Error - ajax

I got following error
Method get_slotsAjax does not exist
my call in healper file
xmlhttp.open("GET","?option=com_ajax&module=quickcontact&method=get_slots&format=json",true);
my function call
public function get_slots()
{
....
}
Went by this documentation.
What am I Missing?

Your method name must end with "Ajax" as mentioned in the documentation.
NOTE: All methods must end in Ajax.
For example:
method=mySuperAwesomeMethodToTrigger will call
mySuperAwesomeMethodToTriggerAjax
So your method name would be as there in the error
get_slotsAjax

Related

Customise the "method is not supported for this route" error handling in Laravel

Route::post('order', 'OrderController#store')->name('order');
When I browse to the URL http://127.0.0.1:8000/order it shows the error:
The GET method is not supported for this route. Supported methods: POST.
Which is the correct.
But I want to redirect user to home page instead of showing this error.
First of all note that what you are trying to do seems like an anti-pattern for Laravel. Accessing a route with the wrong method should be denied!
I currently do not know about altering the default way of handling the wrong method error and I wouldn't advise to do that. But you can work around it:
Patching
Method 1
Keep your routes file clean but alter the original route line and add some lines to the beggining of the controller method
Route::match(['get', 'post'], 'order', [OrderController::class, 'store'])->name('order');
public function store(Request $request)
{
if ($request->isMethod('get')) {
return to_route('home');
}
// ...
Method 2
Keep your controller clean, but add a line to your routes file
Route::get('order', fn () => to_route('home'));

Message: Call to undefined method CI_Input::manufacturer()

can somebody tell me what's wrong with this code? This is located in my controller. I have an error message "Message: Call to undefined method CI_Input::manufacturer()"
public function edit_manufacturer(){
$this->load->helper("security");
$id = $this->uri->segment(3);
if($this->input->manufacturer('submit')){
$manufacturer_name = $this->security->xss_clean($this->input->manufacturer('manufacturer_name'));
$this->asset_model->edit_manufacturer($manufacturer_id, $manufacturer_name);
}
}
input is a reserved class from CodeIgniter and the methods are the following
$this->input->post();
$this->input->get();
$this->input->cookie();
$this->input->server();
therefore, manufacturer method doesn't exist unless you modified this class and created the method.
Maybe what you want to do is:
$this->input->post('manufacturer');
or
$this->input->post('submit');
For more information visit Input Class Documentation

CodeIgniter - calling method from a variable

Let's keep it simple.
We have this:
public function db($method)
{
$this->$method.'()';
}
I'am sure this is pretty self explanatory. Basically I want all my methods to be called trough this method 'db', but this is the error:
Message: Undefined property: site::$db
Ehm...
I guess I could write all the possible cases by hand, but is it really necessary??
Did you tried call_user_func($function);
Or
$this->$function()
Or
$this->{$function}()

Laravel 4 route-model binding exceptions doesn't work despite docs and examples

I read a lot about Laravel4 Route-model binding (L4 docs, tutorials, etc.) but still exceptions (i.e. the model is not found) don't work for me
These are my basic files
routes.php:
Route::model('game', 'Game', function(){
// override default 404 behavior if model not found, see Laravel docs
return Redirect::to('/games');
});
...
Route::get('/games/edit/{game}', 'GamesController#edit');
GamesController.php
class GamesController extends BaseController {
...
public function edit(Game $game){
return View::make('/games/edit', compact('game'));
}
}
Pretty straight, but I get this error: Argument 1 passed to GamesController::edit() must be an instance of Game, instance of Illuminate\Http\RedirectResponse given
If I type http://mysite.dev/games/edit/1 all is fine (model with ID = 1 exists)
If I type http://mysite.dev/games/edit/12345 (no model with that ID) the ugly error above is triggered instead of the redirect I specified
I also looked at this (the bottom part where a Redirect closure is suggested: that is just what I am doing!) but no way to make it work: laravel 4 handle not found in Route::model
What's wrong with it? Please any help?
Thanks in advance
In Route::model you declare which variable will be a model instance, you shouldn't use it to do a redirection that way. Instead of that, specify that $game is of type Game and then work with your routes:
Route::model('game', 'Game');
...
Route::get('/games/edit/{game}', 'GamesController#edit');
Then if you access to /games/edit/3 GamesController::edit will receive an instance of Game class whose id=3
I ended up by setting a general "Not Found" error catcher, like this:
// routes.php
App::error(function(Symfony\Component\HttpKernel\Exception\NotFoundHttpException $e) {
return Response::make('Not Found', 404);
});
...
Route::model('game', 'Game');
...
Route::get('/games/edit/{game}', 'GamesController#edit');
What I understand is that if I want a custom redirect and not a general 404 page (i.e. take the user to games' list if model not found), I CAN'T use the route-model-binding
In other words, I have to use Route::get('/games/edit/{id}', 'GamesController#edit'); and then do my application logic inside the 'edit' method:
public function edit($id){
$game = Game::findOrFail($id);
// if fails then redirect to custom page, else go on saving
}
I'm very new to Laravel, but as far as I can see this has nothing to do with the closure, but with the use of "Redirect::to" inside that closure. Using "App::abort( 404 );" works.

call custom controller in magento in java script

I create a custom module named connector,company name is social.in that,there is a controller i.e. Social_Connectors_Customer_AccountController .in this controller ,action method is
public function connectAction()
{
$this->_redirect('customer/account');
}
now,when i call this action method on click of my link,controller is somehow not called.and give me error like :The page you requested was not found, and we have a fine guess why.
java script in my phtml file is:how to call controller's action method in this script?
document.observe('click', function(e){
var target = e.findElement('a[rel^=google]') || e.findElement('button[rel^=google]');
if (target && target.readAttribute('rel')=='google')
{
alert('<?php echo $this->getUrl(); ?>');
}
});
or can anybody say how to call controller on click of my link?
to call controller action,you must have to follow strucure of mvc magento module.and the function getUrl() must be define properly.check its defination.

Resources