+ Start a Discussion
Diwakar G 7Diwakar G 7 

Reading response from Javascript

I am trying to call Javascript from Visualforce page. Below is the sample code of visualforce page. Here I am trying to call get method. I want to see response. Where it will saved? After clicking on preview in developer console JS will be executed. Where to see the response?
<apex:page controller="calljavascript_cls" >


function func()


 var request = new XMLHttpRequest();
 var org_id = '***';
 var user_api_key = '******';

 request.open('GET', 'https://copado.herokuapp.com/json/v1/webhook/metadata/'+org_id+'?api_key='+user_api_key);

 request.onreadystatechange = function () {
 if (this.readyState === 4) {
 console.log('Status:', this.status);
 console.log('Headers:', this.getAllResponseHeaders());
 console.log('Body:', this.responseText);



   <apex:outputText value="{!callfunc}" escape="false"></apex:outputText>


Below code is the JavaScript.
public class calljavascript_cls


public string callfunc{get;set;}
public calljavascript_cls()


 callfunc='<script> func(); </script>';



Thanks and Regards,
Diwakar G​​​​​​​
Khan AnasKhan Anas (Salesforce Developers) 
Hi Diwakar,

Greetings to you!

You can check the response in console tab in chrome.
Open the Developer Tools before you go to that page (View -> Developer -> Developer Tools) as that usually ensures that all the JavaScript is loaded in the debug tools so the link will take you to the code. 

Please refer to the below links which might help you further with the above requirement.



I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas