'Success function not executed even after successfully execution of controller method

Ajax call:

$.ajax({
        type: "GET",
        url: "/promoPricing/promoDiscountDetails",
        data: { 
                materialId : $("#materialId").val(), 
                soldToID :  $("#soldTo").val()
              },
        success: function(result){
            alert("success!");
            console.log(result);
        },
        error: function(eh){
            alert(eh);
            console.log(eh)
          alert('error!');
        }
    });

Controller Method :

@RequestMapping(value = "/promoDiscountDetails", method = RequestMethod.GET)
    public String getDiscountDetails(final Model model) 
    {
        return "hello";
    }

console.log(eh): responseText: "<!doctype html><html lang="en">HTTP Status 404 – Not Found<style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}HTTP Status 404 – Not Found"



Solution 1:[1]

You are getting a 404 Error response, this is not a successful request. It looks like your GET URL and doesn't match your controller's mapping.

Sources

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

Source: Stack Overflow

Solution Source
Solution 1 dylan Poole