0

VF Code:--

<apex:page>
<apex:includeScript value="{!$Resource.jQuery}"/>
<script>
    function myFunction(e){           
    alert('working');
    console.log('Function called');

   console.log('Function running');

    var sessionid = '{!$Api.Session_ID}';

           jQuery.ajax({
                type: "GET",
                url: "https://chatagentURL/chat/rest/System/SessionId",
                headers: {"Authorization" : "OAuth " + sessionid, "Content-Type": 'application/json', "X-LIVEAGENT-API-VERSION":'40', "X-LIVEAGENT-AFFINITY":'null', "Access-Control-Allow-Origin": '*',"Access-Control-Allow-Credentials": 'true'},
                crossDomain : true,
                success: function (responseData) {
                    console.log('responseData---',responseData);
                    debugger;
                    alert(responseData.records);
                    var m  =  responseData;
                },
                error: function (request, status, error) {
                debugger;

                                    console.log('request'+JSON.stringify(request));
                                    alert('request'+JSON.stringify(request));
debugger;
                }
            });


    }
</script>
<apex:form >

    <!--<apex:actionFunction name="callMethod" action="{!callMethod}" onComplete="showSuccess()"/>
-->
        <apex:PageBlock >
            <div align="center" draggable="false" >
              <!--  <apex:CommandButton value="API Check" onclick="myFunction()" />-->
              <button onclick="myFunction()">API Check</button>
            </div>
        </apex:PageBlock>
    </apex:form>    
</apex:page>
| improve this question | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.