function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
App_Dev1App_Dev1 

How to use the AJAX 8.0 toolkit from an external web page?

I am trying to use the 8.0 AJAX API to pull salesforce information into an external page.  Having trouble with this with winter 07 and the new AJAX API.

Pre release winter 07 location: https://prerelna1.pre.salesforce.com
Ajax 8.0 Javascript:  https://prerelna1.pre.salesforce.com/soap/ajax/8.0/connection.js

I have tried setting sforce.connection.ur manually to https://prerelna1.pre.salesforce.com or https://prerelna1.pre.salesforce.com/services/Soap/u/8.0 with no luck.

Im sure I am missing something simple.  How do I do this?  Does anyone have a sample page?  Are the samples from the AJAX Beta 3 going to be updated?

Appreciate the help!
cheenathcheenath
You can find AJAX Toolkit 8.0 docs here:

http://www.salesforce.com/us/developer/docs/ajax/apex_ajax.pdf

To include the toolkit you need to have the following script tag:
      <script src="/soap/ajax/8.0/connection.js"></script>

Complete example here:


    <html>
      <script src="/soap/ajax/8.0/connection.js"></script>
      <script type="text/javascript">
        function setup() {
            var callback = {onSuccess: display, onFailure: failed};
            var userInfo = sforce.connection.getUserInfo(callback);
        }

        function display(userInfo) {
            var doc = document.getElementById("name-span");
            doc.innerHTML = userInfo.userName;
        }

        function failed(error) {
            document.getElementById("name-span").innerHTML =
               error.toString();
        }
      </script>
      <body onload="setup()">
      Hi there! <span id="name-span"></span>
      </body>
    </html>







cheenathcheenath


App_Dev1 wrote:
I am trying to use the 8.0 AJAX API to pull salesforce information into an external page.  Having trouble with this with winter 07 and the new AJAX API.



Browsers same origin policy will not allow pages served from external servers to talk to Salesforce.com using AJAX Toolkit. So the page must be hosted by Salesforce.com (SControls) or you have to tweak browsers security config (not recommended).
james_galindojames_galindo


App_Dev1 wrote:
I am trying to use the 8.0 AJAX API to pull salesforce information into an external page.  Having trouble with this with winter 07 and the new AJAX API.


You CAN however load an outside web page (e.g. .aspx) by including a ref to it in your s-control and then use the AJAX toolkit all day long. :smileyhappy: