0

我在发送 ajax 身份验证请求时遇到问题.. 我没有收到错误,但 chrome 中的网络说:方法:获取,状态:已取消,类型:挂起,并且此请求没有响应..当我单击文件连接时.js 它指向这一行:

             // start the request!
              xhr.send(requestOptions.data);

& 我的路径名和方法 get 的颜色为 RED

这是我的代码:

   Ext.onReady(function() {
          Ext.Ajax.request({
        url: 'https://api.mysite.com/api/oauth/',
        method: 'GET',
        useDefaultXhrHeader:false,
        disableCaching: false,
        timeout:120000,

        params: {
            client_id: 'xxxxxx',
            client_secret: 'xxx',
            format: 'json'
        },
        success: function(response) {

            var resultat = Ext.JSON.decode(response.responseText);
     //the response is :           {"status":"ok","auth_token":"xxxxxxxxxxx"}
            if (resultat.status === "ok") {
                if (!resultat.access_token === "") {

                    access_token = resultat.access_token;
                    me.sessionToken = resultat.sessionToken;
                }
                else
                {
                    new Ext.Ajax.request({
                        url: 'https://api.mysite.com/api/oauth/signin',
                        method: 'post',
                        params: {
                            username: username,
                            password: password,
                            authtoken: resultat.access_token,
                            format: 'json'
                        },
                        success: function(response) {

                            var loginResponse = Ext.JSON.decode(response.responseText);

                            if (loginResponse.success === "true") {
                                // The server will send a token that can be used throughout the app to confirm that the user is authenticated.
                                me.sessionToken = loginResponse.sessionToken;
                                me.signInSuccess();     //Just simulating success.
                            } else {
                                me.signInFailure(loginResponse.message);
                            }
                        },
                        failure: function(response) {
                            me.sessionToken = null;
                            me.signInFailure('Login failed. Please try again later.');
                        }

                    });

                }
                // The server will send a token that can be used throughout the app to confirm that the user is authenticated.


            } else {
                //exception
            }
        }
           ,
           failure: function(response) {
                 me.sessionToken = null;
                  Ext.Msg.alert('failed !!');    // its what it shows me 
                }
         });
4

0 回答 0