How to FlexAjax?

I have a question. I need to make PHP Request to my FelexAjax Function in vTiger, can anybody help?

This is my code: MenuReorder.php

class Settings_FlexSuite_MenuReorder_Action extends Settings_Vtiger_Basic_Action { public function process(Vtiger_Request $request) { $adb = \PearDatabase::getInstance(); $modules = \FlexSuite\VtUtils::getEntityModules(true); echo json_encode($modules); } public function validateRequest(Vtiger_Request $request) { $request->validateWriteAccess(); }
}

This is my code: MenuEditor.js

$( document ).ready(function() { FlexAjax("FlexSuite").postSettingsAction("MenuReorder", { parameter1:value1 }, "json").then(function(response) { var RecordLabel = response.label; });
});
1

1 Answer

Use the following code: PHP Side:

class Settings_FlexSuite_MenuReorder_Action extends Settings_Vtiger_Basic_Action { public function checkPermission(Vtiger_Request $request) { $currentUser = Users_Record_Model::getCurrentUserModel(); if(!$currentUser->isAdminUser()) { throw new AppException(vtranslate('LBL_PERMISSION_DENIED', 'Vtiger')); } } public function process(Vtiger_Request $request) { $adb = \PearDatabase::getInstance(); $modules = \FlexSuite\VtUtils::getEntityModules(true); $response = new Vtiger_Response(); $response->setResult($modules); $response->emit(); }
}

Java Script Code:

$( document ).ready(function() { params = { data: { module: 'FlexSuite', parent: 'Settings', action: 'MenuReorder', } }; app.helper.showProgress(); app.request.post(params).then(function(error, data) { app.helper.hideProgress(); if(error === null) { var RecordLabel = data.label; app.helper.showSuccessNotification({message: RecordLabel}); } });
});
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like