Jump to content

How to handle only a json data in a module


SametALMDR

Recommended Posts

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? 

Link to comment
Share on other sites

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;


} 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated