Skip to main content Join the Agentforce Virtual Hackathon to build innovative solutions and compete for a $50k Grand Prize. Sign up now. Terms apply.
Hi,

 

We are facing an issue with cross-domain access when trying to connect to CTI via a visual force page. While we are able to get a CTI response from a regular HTML page, we do not get any response when the same is run from salesforce. We have used jquery to handle the cross -domain restriction but looks like it is not helping.

 

The vf code is as below:

 

------------------------------------------------------------------

 

<apex:page >

 

<html>

 

<body>

 

<h1>

 

Cross-Origin Resource Sharing (CORS) With jQuery And Node.js

 

</h1><br/>

 

<h2>

 

PUT Response

 

</h2>

 

<pre id="putResponse">

 

<!-- To be populated dynamically. -->

 

</pre>

 

<h2>

 

DELETE Response

 

</h2>

 

<pre id="deleteResponse">

 

<!-- To be populated dynamically. -->

 

</pre>

 

<!-- Load our JavaScript and make some CORS requests. -->

 

<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.js"></script>

 

<script type="text/javascript">

 

// Wrap up the PUT request execution.

 

var makePUTRequest = function(){

 

// Make the PUT request.

 

$.ajax({

 

type: "POST",

 

url: "http://localhost:8080/AgentBridge",

 

contentType: "text/xml",

 

data: loginRequest('(336) 626-8313'),

 

dataType: "xml",

 

success: function( response ){

 

// Put the plain text in the PRE tag.

 

$( "#.putResponse" ).text( response );

 

},

 

error: function( error ){

 

// Log any error.

 

console.log( "ERROR:", error );

 

alert(error);

 

},

 

complete: function(){

 

// When this completes, execute teh

 

// DELETE request.

 

alert('complete process');

 

}

 

});

 

};

 

function loginRequest(numb) {

 

var req='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webservice.bridge.client.integrations.five9.com/">'

 

+'<soapenv:Header/>'

 

+'<soapenv:Body>'

 

+'<web:startClick2Dial>'

 

+'<arg0>'+numb+'</arg0>'

 

+'</web:startClick2Dial>'

 

+'</soapenv:Body></soapenv:Envelope>';

 

return req;

 

}

 

// Execute the PUT request.

 

makePUTRequest();

 

</script>

 

</body>

 

</html>

 

</apex:page> 
1 answer
0/9000