Passing parameters through HTTP Adapter?

前端 未结 1 1184
温柔的废话
温柔的废话 2021-01-23 23:34

I want to send an email to the user after he/she sign\'s up in my hybrid application (based on IBM Worklight 6.0).

I want to pass the parameters (email ID) of the user t

1条回答
  •  春和景丽
    2021-01-24 00:21

    Where is the parameter? You are not passing it to the adapter procedure AFAICT.

    Try the below (I did not test it end-to-end, as I don't have a server with a PHP script listening to requests).

    HTML

    Your email address: 
    
    

    JavaScript

    function sendEmail() {
        var invocationData = {
                adapter : 'myAdapter',
                procedure : 'sendEmailProcedure',
                parameters : [$('#emailaddr').val()] // the email adrress taken from the HTML...
        };
    
        var options = {
                onSuccess : success,
                onFailure : failure
        };
    
        WL.Client.invokeProcedure(invocationData, options);
    }
    
    function success() {
        WL.Logger.debug ("invocation succeeded.");
    }
    function failure() {
        WL.Logger.debug ("invocation failed.");
    }
    

    myAdapter.xml

    ...
    ...
    
        
            http
            host-address
            80 
        
        
    
    
    
    

    myAdapter-impl.js

    function sendEmailProcedure(emailAddress) {
        var input = {
            method : 'get',
            returnedContentType : 'html',
            path : '/email.php?a=' + emailAddress
        };
    
        return WL.Server.invokeHttp(input);
    }
    


    See related questions:

    • IBM Worklight - How to pass parameters from the application to the adapter?
    • IBM Worklight 6.1 - How to send post values in adapter?

    0 讨论(0)
提交回复
热议问题