Encountering a 404 Error When Making an Ajax Request in Spring MVC

Looking to implement a basic login form using Spring MVC and an APIResponseModel class with Status, Message, HTTPStatus variables. After submitting the credentials, receiving a 404 ajax response, although the Controller returns {"status":"200","message":"Login Success!!","data":Admin}. Need assistance in resolving this issue.

Spring Controller

@RequestMapping("/login")
    public APIResponseModel getLoginPage(@ModelAttribute("loginUser")UserDTO userDto, HttpSession session) {
        // Code block
    }

Validate login JS Function

function processLogin(e){
    // Code block for processing login
}

MasterAjax class

class MasterAjax{
    constructor(){
        // Constructor code
    }
    
    requestData(callBack){
        // Method to request data
    }
    
}

LoginForm

<form class="page" name="loginForm">
 <input class="email" id="email" path="email"  type='text' align="center" placeholder="Username / Email" />
  <input class="pass" id="password" path="password" type='password' align="center" placeholder="Password" />
  <button class="submit" onclick="processLogin(event)">Sign in</button>
  <p class="forgot" align="center"><a href="#">Forgot Password?</a></p>
</form>

Answer №1

The controller missed including @ResponseBody, causing the response not to be sent when called.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Grid Column with Checkboxes in Kendo UI for Vue

Seeking help in adding a checkbox column to a Kendo UI Vue grid. The column should display the values of a boolean field from the grid's data source. While I am aware of how to add a checkbox column for selection as demonstrated here: https://www.tele ...

What is the best way to clear the content of a contenteditable element in React?

I have a scenario where I am rendering an array of items, each with a contenteditable field. MainComponent.js import { useState } from "react"; import Item from "./Item"; import "./styles.css"; export default function MainC ...

Inspecting the final element of my jQuery slider

I've been working on a jQuery slider where I add the class "currentmemory" to each child of my memory2container to show which slider is displayed. The issue arises when I reach the last slider; instead of looping back to the first one and starting ov ...

How to programmatically update one input value in AngularJS and trigger validation as if it was manually entered by the user?

I'm currently using Angular 1.3.0rc2 and facing an issue with setting one input field based on another input field after the blur event. When I try to set the value of an input field that only has a synchronous validator, everything works fine by usi ...

Tips for updating Nodejs' module dependency to a newer version

Currently, my project utilizes the react-cropper library which includes version cropper ^0.10.0. However, I require certain methods from cropper version 0.11.1. To address this issue, I decided to fork the project to my own GitHub repository in order to up ...

Text field suddenly loses focus upon entering a single character

In my current code, I have functions that determine whether to display a TextField or a Select component based on a JSON value being Text or Select. However, I am facing an issue where I can only enter one letter into the TextField before losing focus. Sub ...

Twitter: cease monitoring stream events following X callback

//Just starting out with node.js I'm new to using ntwitter for listening on twitter statuses. Is there a way to stop listening after a certain number of callbacks have been called? var twittsCounter = 0; twit.stream('statuses/filter', { ...

Exploring the possibilities of Wordpress integration with Fancybox and Ajax

I am currently using FancyBox in WordPress to display a contact form. However, I am encountering an issue with submitting the form using AJAX. When I tested the AJAX call outside of the WordPress environment, it worked perfectly fine. Can someone please as ...

Using jQuery or JavaScript, extract JSON data from Yahoo Pipes

Here is the JSON format that I receive from Yahoo pipes: {"count":3, "value":{ "title":"Freak count feed", "description":"Pipes Output", "link":"http:\/\/pipes.yahoo.com\/pipes\/pipe.info?_id=565sdf6as5d4fas ...

Can you explain the distinction between JSON syntax and object assignment in programming?

While exploring the Twitter Client example on Knockoutjs, one may notice that some properties are included in the JSON object while others are assigned outside of it. What distinguishes these two approaches? And why can't methods such as findSavedList ...

Is it possible to trigger the @click event in Vuejs when utilizing v-html to render HTML content?

Here is an interesting HTML scenario: errorText: '<a class="button" @click.prevent="enableExceedable(issue.mapping)">Enable exceedable limits</a>'; I am trying to insert this string into the following div: <div v-if="hasIssue != ...

Tips for utilizing navigator.getDisplayMedia with automatic screen selection:

navigator.mediaDevices.getDisplayMedia({ audio: false, video: true }).then(gotMedia).catch(function(e) { console.log('getDisplayMedia() error: ', e); }); Triggering the above code will result in a popup like this. There is anoth ...

Utilizing directives while initiating dynamic components

I've been exploring the capabilities of dynamically creating components using the ComponentFactoryResolver. const factory = this.componentFactoryResolver.resolveComponentFactory(FooComponent); const component = this.templateRoot. ...

The jQuery .load function doesn't seem to be functioning properly when used within a partial view displayed inside a modal popup

I am facing an issue with loading a partial view via ajax call in my main view. The modal popup is displayed when the "AddSkillBtn" button is clicked, but I need to trigger an ajax call when the partial view is loaded. However, using .on 'load' d ...

Toggle class on element based on presence of class on another element

If I have 4 boxes and the user is required to choose one. I aim to assign an active class to the box that the user clicks on. However, if the user selects another box, I want to remove the class from the first clicked box and apply it to the newly clicked ...

Exploring Angular2: A Guide to Interpolating Expressions in Templates

Is it possible to interpolate different types of Javascript expressions? Along with displayed properties like object.property and short expressions such as {{1+1}}, what other valid Javascript expressions can be used for interpolation? ...

Why does the styling of the inner Span adhere to the style of the outer Span?

How can I adjust the opacity of the color "blue" to 1 in the code snippet below? <!DOCTYPE html> <html> <body> <p>My mom's eyes are <span style="color:blue;font-weight:bold;opacity:0"> <span style="color:blue;fo ...

Click on the hyperlinks one by one that trigger ajax events

There is a feature on the popular social media platform reddit.com where you can load more comments by clicking a link. I understand that comments may be hidden for performance reasons, but I would like to automatically expand all comments without having t ...

Struggling to implement dynamic templates in an Angular directive

In the process of developing a small angular application that consists of 3 modes - QA, Production, and Sandbox. In the QA mode, there are multiple buttons for users to select values which then populate "myModel". The other two modes, Production and Sandbo ...

When trying to deploy to Heroku, node-gyp encounters an issue installing [email protected] and ultimately fails to rebuild

I am currently facing an issue with deploying a nodejs application on Heroku due to the node-gyp rebuild error associated with the base64 library. I have successfully run the application locally, but deployment on Heroku seems to be problematic. Any sugges ...