简体   繁体   English

我尝试使用jquery ajax使用服务时无法获取JSON响应

[英]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&username=manoj6893@gmail.com&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>

When i try to hit salesforce.com using oAuth 2.0 in jQuery I am getting following error. 当我尝试在jQuery中使用oAuth 2.0访问salesforce.com时,出现以下错误。

Failed to load resource: the server responded with a status of 400 (Bad Request) 加载资源失败:服务器响应状态为400(错误请求)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM