(Amr) Posted October 4, 2017 Share Posted October 4, 2017 (edited) Before WHMCS v7.3, developers used to post Ajax requests to "addonmodules.php?module=module_name". With WHMCS v7.3, that doesn't work if the current URL is a virtual path "i.e /admin/setup/authn/view". After checking the new JavaScript files, it seems that, there is an internal method to translate/get valid paths, and it's called as follows : WHMCS.adminUtils.getAdminRouteUrl('/path/to/get'); Since this is not -yet- a documented method , could you please let me know, how to use this method to get addon modules valid path ? Edited October 4, 2017 by (Amr) 0 Quote Link to comment Share on other sites More sharing options...
(Amr) Posted October 5, 2017 Author Share Posted October 5, 2017 In-case someone else is wondering, here is the official reply I just received, thanks to @WHMCS Nate : Quote Hello Amr, We provide two variables in global scope for JS that should allow you to build ajax calls to addon modules within pages in the new v7.3 admin routes. You can provide absolute paths to your AJAX request utilizing the following: 'whmcsBaseUrl': a global scope variable available in either client or admin areas. It's value the absolute path of the WHMCS directory on the domain 'adminBaseRoutePath': a global scope variable available in the admin area. It's value is the name of the (custom) admin directory (ie, the relative path from 'whmcsBaseUrl' that leads to the admin area) Two Examples: "http://foo.bar/somedir/whmcs/admin/fancy/route" - whmcsBaseUrl = "/somedir/whmcs" - adminBaseRoutePath = "/admin" "http://foo.bar/mycustomadminpath/some_admin_endpoint.php" - whmcsBaseUrl = "" - adminBaseRoutePath = "/mycustomadminpath" So, in your example, you could use the following var mypath = 'addonmodules.php?module=module_name' var request_path = whmcsBaseUrl + adminBaseRoutePath + '/' + mypath; Have a great day, Nate C 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.