SametALMDR Posted September 27, 2021 Share Posted September 27, 2021 (edited) Hello everyone, Is there any way that ı can get only a json data in a module or a hook point ? I want to get a data to my module by clicking a button that gets the data from this page using ajax. Please guys help mee 😞 Edited September 27, 2021 by SametALMDR 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted September 27, 2021 Share Posted September 27, 2021 To get json in to WHMCS's chain / given variables and thus in to its hooks and supported module functions, you would need to pass it as a POST variable in the ajax request. If the whole POST has to be a json post, then this requires a separate file you can post to and that php file would expect php://input to be json -- can't give example due to web filters but a google search should for that should show the code. That file then needs to include the init.php file and such if it wants to access parts of WHMCS . What would be the use case here? 0 Quote Link to comment Share on other sites More sharing options...
developer _WHM_CS Posted October 1, 2021 Share Posted October 1, 2021 WHMCS developer add a function in JS file and you can use it WHMCS.http.jqClient.jsonPost({ url: "modules url",// adminerea: addonmodules.php?module=yourMudole clientarea index.php?m=yourMudole data: { // it must be include token vars1: 'data1', vars2: data2, token: csrfToken }, success: function (data) { if (data.success) { //do actin } }, error: function (error) { if (error) { } } }); you can access $_ POST in function youMudole_output($parms){} or function youMudole_clientarea($parms){} for generate response function youMudole_output($parms){ ob_clean(); echo json_encode($array); die; } 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.