Welcome Guest, Not a member yet? Register   Sign In
Best practice for AJAX quieries
#4

(09-03-2018, 09:11 AM)InsiteFX Wrote: As long as you check in your controllers for an Ajax request you should be ok.

PHP Code:
// Check for AJAX request.
if ($request->isAJAX())
{
 
       . . .


Yes it's good for minimal AJAX queries, but I have controllers with example 5-10 Ajax actions, and somethink like this:
PHP Code:
if($request->isAJAX()) {
    switch(
$task) {
        case 
'action1':
                
/**
                 * When action have many lines it's very hard to work fine with this
                 */
            
break;
        case 
'action1':
            break;
        case 
'action2':
            break;
        case 
'action3':
            break;
        case 
'action4':
            break;
        case 
'action5':
            break;
        ....
    }


So, I start thinking about declare Other Controller (namspace?) for AJAX. Ex.: method names as actions and resolve this to maybe better way.
Reply


Messages In This Thread
Best practice for AJAX quieries - by Przem4S - 09-03-2018, 06:01 AM
RE: Best practice for AJAX quieries - by InsiteFX - 09-03-2018, 09:11 AM
RE: Best practice for AJAX quieries - by Leo - 09-03-2018, 02:29 PM
RE: Best practice for AJAX quieries - by Przem4S - 09-04-2018, 12:57 AM
RE: Best practice for AJAX quieries - by puschie - 09-04-2018, 02:19 AM
RE: Best practice for AJAX quieries - by InsiteFX - 09-04-2018, 04:01 AM
RE: Best practice for AJAX quieries - by Przem4S - 09-04-2018, 04:14 AM
RE: Best practice for AJAX quieries - by puschie - 09-05-2018, 02:39 AM



Theme © iAndrew 2016 - Forum software by © MyBB