阅读背景:

Unable to get the JSON response while I try to consume a service using jquery ajax

来源:互联网 
<html>
<head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
</head>
<body>
    <h3>REST API With Javascript</h3>
    <button id="connect">Connect</button>

    <script type="text/javascript">
        $(document).ready(function(){
            function Contact(access_token, instance_url, id, token_type, issued_at, signature) {
                this.access_token = access_token;
                this.instance_url = instance_url;
                this.id = id;
                this.token_type = token_type;
                this.issued_at = issued_at;
                this.signature = signature;

                this.toJsonString = function () { 
                    return JSON.stringify(this); 
                }
            }

            $('#connect').click(function(){  
                jQuery.ajax({
                    type: "POST",
                    url: "https://login.salesforce.com/services/oauth2/token?grant_type=password&client_id=3MVG9ZL0ppGP5UrBcvLyXYRmRUuYKSgFgQayclpZBWmbi7PQ2vWj1V8Xev.GfE0C9xyWMrTzONlj2GZ0ow6VK&client_secret=2150505966475551576&[email protected]&password=9989832835j4oKKODMzqViqjJ2ORFEogUokh",
                    data: Contact,
                    dataType: "application/json; charset=utf-8",
                    success: success_callback,
                    error: error_callback, 
                    dataType: "jsonp"  
                });
            });

            function success_callback(jqXHR, textStatus, errorThrown) {
                alert('fail');
            }

            function error_callback(data, textStatus, jqXHR) {
                alert('success');
            }
        });
    </script>
</body>
</html>
<html>
<head>
    <script src="https://ajax.goo



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: