title: The ajax function does a get to another url but does not succeed
body: <p>I'm working with springBoot, where I have my html code in the resources folder.
  To run my project I have the following docker:</p>
  <pre><code>version: &quot;3.1&quot;
  
  services:
      dataBase:
          image: mysql:8.0
          ports: 
              - &quot;3306:3306&quot;
          environment:
              MYSQL_DATABASE: fastTravelDB
              MYSQL_USER: admin
              MYSQL_ROOT_PASSWORD: admin
              MYSQL_PASSWORD: admin 
          volumes:
              - datafiles:/var/lib/mysql
          networks:
              - default
          restart: always
  
      fasttravelservice:
        depends_on:
          - dataBase
          - messageBroker
        build: ./FastTravelService
        restart: on-failure
        ports:
          - 6868:8000
        environment:
          SPRING_APPLICATION_JSON: '{
            &quot;spring.datasource.url&quot;  : &quot;jdbc:mysql://dataBase:3306/fastTravelDB?useSSL=true&quot;,
            &quot;spring.datasource.username&quot; : &quot;admin&quot;,
            &quot;spring.datasource.password&quot; : &quot;admin&quot;,
            &quot;spring.jpa.properties.hibernate.dialect&quot; : &quot;org.hibernate.dialect.MySQL8Dialect&quot;,
            &quot;spring.jpa.hibernate.ddl-auto&quot; : &quot;update&quot;,
            &quot;server.port&quot;: 8000,
            &quot;spring.rabbitmq.username&quot; : &quot;user1&quot;,
            &quot;spring.rabbitmq.password&quot; : &quot;user1&quot;,
            &quot;spring.rabbitmq.host&quot; : &quot;messageBroker&quot;,
            &quot;spring.rabbitmq.port&quot; : 5672
          }'
  </code></pre>
  <p>I'm running my website at the door http://localhost:6868</p>
  <p>I have the following form in an html page, where I call the <strong>checkLogin()</strong>, when I click on button.</p>
  <pre><code>&lt;form&gt;
    &lt;div class=&quot;form-group&quot;&gt;
      &lt;label class=&quot;label&quot;&gt;Email&lt;/label&gt;
      &lt;div class=&quot;input-group&quot;&gt;
        &lt;input id=&quot;emailId&quot; type=&quot;text&quot; class=&quot;form-control&quot; placeholder=&quot;Email&quot;&gt;
        &lt;div class=&quot;input-group-append&quot;&gt;
          &lt;span class=&quot;input-group-text&quot;&gt;
            &lt;i class=&quot;mdi mdi-check-circle-outline&quot;&gt;&lt;/i&gt;
          &lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class=&quot;form-group&quot;&gt;
      &lt;label class=&quot;label&quot;&gt;Password&lt;/label&gt;
      &lt;div class=&quot;input-group&quot;&gt;
        &lt;input id=&quot;passwordId&quot; type=&quot;password&quot; class=&quot;form-control&quot; placeholder=&quot;*********&quot;&gt;
        &lt;div class=&quot;input-group-append&quot;&gt;
          &lt;span class=&quot;input-group-text&quot;&gt;
            &lt;i class=&quot;mdi mdi-check-circle-outline&quot;&gt;&lt;/i&gt;
          &lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class=&quot;form-group&quot;&gt;
      &lt;button class=&quot;btn btn-primary submit-btn btn-block&quot; style=&quot;
      font-size: 16px;font-weight: 600; background-color: #F96E46; border: none; color: #111111&quot; onclick=&quot;checkLogin()&quot;&gt;Login&lt;/button&gt;
    &lt;/div&gt;
    
    &lt;div class=&quot;text-block text-center my-3&quot;&gt;
      &lt;span class=&quot;text-small font-weight-semibold&quot;&gt;Not a member ?&lt;/span&gt;
      &lt;a href=&quot;register&quot; class=&quot;text-black text-small&quot;&gt;Create new account&lt;/a&gt;
    &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  <p>The function does a get on a url http://localhost:6868/login/check, but the sucess in ajax is never achieved.</p>
  <pre><code>    &lt;script&gt;
        function checkLogin() {
  
          var email = document.getElementById(&quot;emailId&quot;).value;
          var password = document.getElementById(&quot;passwordId&quot;).value;
  
          if (email == &quot;&quot; || password == &quot;&quot;) {
            alert(&quot;All fields must be filled!&quot;);
            return true;
          }
  
          const url = 'http://localhost:6868/login/check';
          if (email != null) {
            alert(&quot;HREF &quot;, window.location.href)
            $.ajax(url, {
              type: 'GET',
              data: { email: email, password: password },
              success: function (result) {
                alert(&quot;ENtrei no sucess!&quot;)
                var obj = JSON.parse(result);
                alert(&quot;ENtrei no sucess2!&quot;)
                if (obj.state == true) {
                  localStorage.setItem(&quot;email&quot;, email)
                  localStorage.setItem(&quot;firstName&quot;, obj.firstName)
                  localStorage.setItem(&quot;lastName&quot;, obj.lastName)
                  alert(email)
                  window.location.href = &quot;http://localhost:6868/client/home&quot;;
                  return true;
                } else {
                  alert(obj.error);
                }
              },
              error: function(error) { 
                console.log(error) 
              }
            });
          }
          return false;
        }
      &lt;/script&gt;
  </code></pre>
  <p>Here is the spring boot code that is called after the get url http://localhost:6868/login/check :</p>
  <pre><code>@RestController
  public class LoginCheckController {
  
      @Autowired
      private ClientService clientService;
  
      @CrossOrigin(origins =&quot;http://127.0.0.1:6868/login&quot;)
      @GetMapping(&quot;/login/check&quot;)
      public String getLogin(String email, String password) throws ResourceNotFoundException {
          Client client = clientService.getClientByEmail(email);      
  
          if(client != null &amp;&amp; client.getPassword().equals(password)) {
              System.out.println(&quot;{\&quot;state\&quot;: true, \&quot;firstName\&quot;: \&quot;&quot; + client.getFirst_name() +&quot;\&quot;, \&quot;lastName\&quot;: \&quot;&quot; + client.getLast_name() + &quot;\&quot; }&quot;);
              return &quot;{\&quot;state\&quot;: true, \&quot;firstName\&quot;: \&quot;&quot; + client.getFirst_name() +&quot;\&quot;, \&quot;lastName\&quot;: \&quot;&quot; + client.getLast_name() + &quot;\&quot;}&quot;;
          }
          return &quot;{\&quot;state\&quot;: false, \&quot;error\&quot;: \&quot;Email and password incorrect!\&quot;}&quot;;
      }
  }
  </code></pre>
  <p>In short, I would like to know why the success part of ajax is never performed.</p>