"Despite providing the correct code, my Loader is failing to work properly - what could be the reason

When I press the button, my loader and form are not showing up. The loader is outside the form, but it is still not working. I've tried to solve this issue multiple times without success. I've also added a `Thread.sleep(3000)` to hold the loader for 3 seconds, but it's still not working. Can someone please help me with this? Below are the details of my `signup.jsp` and `Register.java` code:

package com.user;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.*;

public class Register extends HttpServlet {

   protected void processRequest(HttpServletRequest request, HttpServletResponse response)
           throws ServletException, IOException {
       response.setContentType("text/html;charset=UTF-8");
       try (PrintWriter out = response.getWriter()) {
           /* TODO output your page here. You may use following sample code. */
           /*out.println("<!DOCTYPE html>");
           out.println("<html>");
           out.println("<head>");
           out.println("<title>Servlet Register</title>");            
           out.println("</head>");
           out.println("<body>");*/
           //Getting all the details from incoming from request
           String name=request.getParameter("user_name");
           String email=request.getParameter("user_email");
           String password=request.getParameter("user_password");
           //out.println(name);
           //out.println(email);
           //out.println(password);
           //connection
            try{
                Thread.sleep(3000);
                Class.forName("com.mysql.cj.jdbc.Driver");
                Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/youtube1","root","Vandana");
                
                //query
                String q="insert into user(name,email,password) value(?, ?, ?)";
                PreparedStatement pstmpt= con.prepareStatement(q);
                pstmpt.setString(1, name);
                pstmpt.setString(2, password);
                pstmpt.setString(3, email);
           
                
                pstmpt.executeUpdate();
                
                out.println("Done");
            } 
            
            catch (Exception e){
               e.printStackTrace() ;
               out.println("Error");
            }

           
           
           //......
           //out.println("</body>");
           //out.println("</html>");
       }
   }

   // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
   /**
    * Handles the HTTP <code>GET</code> method.
    *
    * @param request servlet request
    * @param response servlet response
    * @throws ServletException if a servlet-specific error occurs
    * @throws IOException if an I/O error occurs
    */
   @Override
   protected void doGet(HttpServletRequest request, HttpServletResponse response)
           throws ServletException, IOException {
       processRequest(request, response);
   }

   /**
    * Handles the HTTP <code>POST</code> method.
    *
    * @param request servlet request
    * @param response servlet response
    * @throws ServletException if a servlet-specific error occurs
    * @throws IOException if an I/O error occurs
    */
   @Override
   protected void doPost(HttpServletRequest request, HttpServletResponse response)
           throws ServletException, IOException {
       processRequest(request, response);
   }

   /**
    * Returns a short description of the servlet.
    *
    * @return a String containing servlet description
    */
   @Override
   public String getServletInfo() {
       return "Short description";
   }// </editor-fold>

}

**signup.jsp** 

...

Answer №1

https://i.sstatic.net/Oa1gh.png

No, the location is not external. There seems to be an issue with the form class being used in two places. The loader should be placed outside of the form, not outside of the form class. Please refer to the image for clarification.

Edit:

error:function(jqXHR,textStatus,errorThrown){
                          console.log("error");
                          $(".loader").hide();
                          $(".form").show();
                          $("#msg").html("Something went wrong !!!");
                          $("#msg").addClass("red-text");
                      }

Please remove console.log(data); from your error function. If the issue persists, check the console for any errors.

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

How to Implement Filtering in AngularJS ng-repeat

While developing my app, I came across a challenge with the filter in my ng-repeat. Initially, I could search by productCode or name. Then, a new requirement emerged - "Filter by SubcategoryId." The issue lies in filtering strictly by subCategoryId, while ...

Is there a way to redirect using Express JS when the destination is

Hello there, I'm encountering an issue with redirecting in express js. I have a function that should trigger when a submit button is pressed and then redirect to a different page. However, when using res.redirect('/results.ejs');, I receive ...

Check if the number field in the If statement is empty or contains an excessive number of decimal places, while excluding cases where only zeroes are present in the decimal places

I am currently working with the following line of code: if ($val === "" || ($val.split(".")[1] || "").length > 2) With some assistance from the helpful individuals here, I have managed to implement this code successfully. ...

Making changes to a variable or option through the props in a different file

In the index.js file, I have implemented getStaticProps() to fetch data from an exported function. This function requires 2 parameters, one for the type of listing and the quantity. export async function getStaticProps() { const type = 0 const data = a ...

`A dynamically captivating banner featuring animated visuals created with JQuery`

I am currently in the process of designing a banner for the top of my webpage, but I have yet to come across any code that meets all my requirements. To provide clarification, I have attached an illustration showcasing what I am aiming to achieve. 1) The ...

Ways to retrieve the related file in Angular service files?

I am looking to retrieve an array from another service file (chart-serv.js) in my return-serv.js service file using AngularJS. How can I reference the dependent file enclosed within double braces [ ], in line 1? return-serv.js var app = angular.module(& ...

Dealing with CORS for an API that facilitates both AJAX requests and server-to-server communication

Currently, I am in the process of developing an endpoint called /v1/getdata. This particular endpoint will be accessed by both ajax and server-to-server requests. However, due to the fact that this endpoint originates from a different source than the websi ...

Is the detailedDescription missing from the JSON-LD schema crawl?

I am currently utilizing the Google Knowledge Graph Search (kgsearch) API to retrieve Schemas from schema.org. However, I am encountering an issue where some nested elements are not being recognized as JSON or I may be overlooking something... url = "http ...

The browser message states: Variable $? Not Found

As a newcomer to javascript (jquery/json), I've created code to display a chart using CanvasJS with a php/json data fetching script. However, I'm facing an issue where the chart is not rendering when I integrate my code. Upon inspecting the brows ...

Angular 2: Troubleshooting Issues with Observable Data Display

Looking to implement a RESTful call with Angular 2 that constantly updates whenever there are changes in the API. In my service, I've included an Observable to fetch data from the API: getData(): Observable<any[]> { return this.http.get(url) ...

Disappearing act: Ionic tabs mysteriously disappear when the back button

Whenever I navigate in my ionic app, I notice that the tabs-bar disappears when I go to different pages and then return to the tabs. See Demo Code tab1 Here is a sample link to navigate to other pages: <ion-label routerDirection="forward" [routerLi ...

Exploring the world of HTTP PUT requests in Angular 4.0

I have encountered an issue with a function I wrote for sending an http put request to update data. The function is not receiving any data: updateHuman(human: Human) { const url = `${this.url}/${human.id}`; const data = JSON.stringify(human); ...

Angular2: Dynamically switch between selected checkboxes in a list

Is there a way to toggle a checked checkbox list in Angular2? I am trying to create a button that, when pressed while the full list is visible, will display only the checked items. Pressing the button again would show the entire list. Here's the Plu ...

Validation for whitelisting in the context of an HTTP request

Currently, I am in the process of developing a servlet request filter that is designed to screen incoming requests using a whitelist character criteria. The objective is to only allow characters that align with the specified whitelist pattern to prevent p ...

By executing array1.splice(1,1), I am deleting elements from array2 that was generated by copying array1 with array1.slice(0)

I was working with JSON data and converted it into an array of objects. Then, I assigned that array to another array using the .slice(0) method. However, I encountered an issue where when I tried to remove an element from the assigned array, it also remov ...

Monitoring Logfile in Ruby On Rails 3.1

Within my Ruby on Rails application, I have a set of scripts that need to be executed. In order to ensure they are working properly, the application must display and track the content of logfiles generated by these scripts. To provide more context: I util ...

Having difficulty transmitting a base64 video via Ajax Post to PHP

While attempting to upload a MP4 video with a size of 16.9 MB via ajax asynchronous post to a PHP file, an error is displayed in the console: POST net::ERR_EMPTY_RESPONSE It seems that the issue is related to the PHP memory_limit setting. When set to 200 ...

express-validator: bypass additional validation in a user-defined validator

Utilizing the express-validator package for validating my request data. As per the documentation, we need to declare them in this manner: app.use(expressValidator({ customValidators: { isArray: function(value) { return Array.isArray(value); ...

NEXT JS - Application renders twice due to rewrites in place

I'm currently working on a NEXT JS project and facing the issue of the app rendering twice! Challenge After implementing rewrites in next.config.js, the app is being rendered twice. Removing the rewrites solves the issue and only renders once. next ...

Menu button is expanded without the need to click

The Bootstrap 5 button extends the default behavior and does not collapse. Here is the code: <nav id="header-nav" class="navbar navbar-expand-lg navbar-light"> <div class="container"> <a class= ...