Forum Stats

  • 3,826,883 Users
  • 2,260,721 Discussions
  • 7,897,110 Comments

Discussions

oracle jet ajax problem

User_XU6OZ
User_XU6OZ Member Posts: 2 Green Ribbon

Hey all I am new to Oracle JET and I have a problem

we try to upgrade our app to version 12 and some of the code that works now does not function well

I try to do login into the app with ajax like before the upgrade and for some reason, I can't understand it not working and I don't get an output\error code that I can try to understand the problem.

this is the code the problem happen :

 await $.ajax({

                    url: self.rootModel.usersLoginRestURL(),

                    data: {

                        username: self.username(),

                        password: self.password()

                    },

                    type: 'POST',

                    xhrFields: {

                        withCredentials: true

                    },

                    error: function (request, status, error) {

                        console.log(`Login Failed.`)

                    },

                    statusCode: {

                        403: function(response) {

                          console.log(`Access Error: (Forbidden) Attempted access to forbidden resource.`);

                          alert(`Incorrect username or password when attempting login.`)

                         },

                        401: function(response) {

                            console.log(`Access Error: (Unauthorized) Incorrect username or password when attempting login.`)

                            alert(`Incorrect username or password when attempting login.`)

                        },

                    },          

                    success: (function (results){

                        const delay = Math.max(100, parseInt(results.accessTokenExpiryMillis) - 5000);

                        setTimeout(self.rootModel.refreshTokens, delay);

                        self.rootModel.accessToken(results.accessToken);

                        self.loginResponse(results)

                        console.log(results);

                    }),

                });


hope you can help.

Answers

  • Nothing should have change in JET v12 in this area. What version are you migrating from? You have a bunch of console.log statements in there, are you getting the same results in those, that you got in your older version?

    If you look at the Network tab in the browser dev tools, is the HTTP request being made at all? At what point does it fail?