Hi in my project I’m working with MVC structure with PHP, MySQL. I’ve got the following route:
http://mywebsite/client/dashboard/index
Then in the controller I show different views according to different user roles. For example one view for client role and one for seller role. I think is better not to create a router specifically for the seller role because I would like to avid code duplication.
To load the javascript files I use the plugin requirejs in this way:
// Load general javascript dependancies
require(['jquery', 'jquery_bootstrap', 'jquery_i18n', 'languages'], function($) {
if(pathArray[1] == 'admin') {
// Load page specific javascript dependancies
require(['admin_controllers', 'notifications'], function() {});
}else if(pathArray[1] == 'client') {
// Load page specific javascript dependancies
require(['client_controllers', 'notifications'], function() {});
}else{
// // Load page specific javascript dependancies
require(['controllers'], function() {});
}
});
So the javascript controller is the same for the client and for the seller.
The questio is how can I fire an ajax function just for the seller for example if it is not required for the client as well? many thanks