'jquery Post works on localhost but not on remote server

I want to get data from the web into a variable in the controller. The following code works on the localhost but not on the remote server. Error "POST 404" is displayed. (error screen)

jquery:

$("button").click(function(e) {
            $.ajax({
                'url': "/enroll/save",
                "data": JSON.stringify(finalTimes),
                'method': "POST",
                'contentType': 'application/json'
            }).done(function (data) {
                alert("Saved !");
            }).fail(function(jqXHR,textStatus,errorThrown){
                alert("Fail !");
            }); 
        });

controller:

@Controller
@Scope(WebApplicationContext.SCOPE_SESSION)
@RequestMapping("/enroll")

public class EnrollControler {
    int[] scannedTimes;
   
    @RequestMapping
    public String enroll(Model model){
        return "enroll";
    }
   
    @PostMapping("/save")
    public String dataArrayUpload(@RequestBody int[] times) {
      this.scannedTimes = times
      return "enroll";
   }
}



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source