Tips for achieving jQuery form submission with Ajax functionality

Currently in my Java application, I am submitting a form using JQuery.

Below is the JSP code snippet:

    <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<fieldset id="profile_proffiesional">
    <form:form action="profile/awards" modelAttribute="AWARDS">
        <p>
            <label for="position">Position</label>
            <form:input path="position" tabindex="4" />
        </p>
        <p>
            <label for="location">Location</label>
            <form:input path="location" tabindex="5" />
        </p>
        <p>
            <label for="description">Description</label>
            <form:input path="description" tabindex="5" />
        </p>
        <p>
            <input type="submit" value="Add">
        </p>
    </form:form>
</fieldset>
<script>
    $('#AWARDS').ajaxForm({
        target : '#body',
        success : function(responseText, statusText, xhr, $form) {
            alert(responseText);
        },
        beforeSubmit : function() {
            $.blockUI({
                message : '<h1> Just a moment...</h1>'
            });
        }
    });
</script>

Upon clicking the Submit button, the form disappears and the response appears within an alert. After closing the alert window by clicking OK, the same success message reappears on the screen instead of remaining hidden.

The issue here is that the form becomes completely invisible, only reappearing when refreshed, removing the success message displayed. Ideally, I want the success message to only appear in the alert and not on the screen itself. Any suggestions on how to achieve this would be greatly appreciated.

Answer №1

Simply remove the line target : '#body' and everything will work perfectly.

This specific line is responsible for updating the contents of the body with the response from the server.

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

When you hover over HTML tables, they dynamically rearrange or shift positions

Issue: I am encountering a problem with multiple tables where, upon hovering over a row, the tables are floating rather than remaining fixed in place. Additionally, when hovering over rows in the first or second table, the other tables start rendering unex ...

Creating a process to produce a random number and send it directly to an automated email

I'm currently utilizing a form builder from jqueryform.com to construct a registration form. My goal is to have each registered user assigned with a unique account number, which will be a randomly generated 6-digit number. Additionally, I want the pro ...

Looking for a way to easily swipe through videos?

My mobile phone viewport displays a series of pictures and videos, with the swipeleft/right function enabled for browsing. However, I noticed that while the swipe feature works fine for images, it stops functioning when a video is displayed. Can anyone p ...

When utilizing jQuery and Ajax for form submission, PHP is unable to retrieve any data

I'm encountering an issue when trying to submit a form with only a radiobutton group named radiob. The script I am using for submitting the data is as follows: <script type="text/javascript"> $(function() { $("#myForm").submit(funct ...

Encountering difficulties inputting text in email body on Selenium using Java

I am trying to implement a function that sends emails using Gmail, but I am facing an issue where the code only sends emails with empty bodies. I suspect that the frame switch is not done correctly. Can someone please guide me on which frame is used for co ...

Set the value received from the AJAX call as a global integer variable

I'm currently facing an issue in my code and struggling to find the error. I have an ajax call that executes an insert statement and returns the ID of the inserted data successfully. However, my goal is to create a global variable for this ID so that ...

The JavaScript code appears to be missing or failing to execute on the website

Encountering a console error while trying to integrate jQuery into my website. The JavaScript file is throwing an error in the console that says: Uncaught ReferenceError: $ is not defined catergory.js:1 Even after following the suggested steps in this an ...

Jquery: Pressing Enter will cause the input field to lose

Take a look at this fiddle I created: http://jsfiddle.net/7wp9rs2s/. This is the progress I have made on my project so far. In the fiddle above, you can double click on one of the 4 items and a textbox will appear for editing. Instead of clicking out of t ...

Learn how to automatically retrieve messages without refreshing the page by leveraging the power of AJAX

displaying notifications with:- $call = "SELECT * FROM `chat` WHERE fromthe = '$email' and tothe='theadmin' UNION ALL SELECT * FROM `chat` WHERE fromthe = 'theadmin' and tothe='$email' order by id desc"; mysqli_quer ...

Ways to extract the value from a jQuery object

How can I retrieve the selected time value using a jQuery plugin and save it on a specific input element within the page? Refer to the plugin and code provided below: http://jsfiddle.net/weareoutman/YkvK9/ var input = $('#input-a'); input.cloc ...

Click on the dropdown item in the Bootstrap btn-group dropdown

I am interested in clicking the dropdown item within the btn-group and triggering an alert message. This is the HTML code I have: <td> <div class="btn-group" role="group"> <button id="btnGroupVerticalDrop2" type="button" class= ...

I encountered a Null Pointer Exception while trying to retrieve information from the Excel spreadsheet

Code: public class ContactFormTest { WebDriver driver; @BeforeMethod public void setUp() { System.setProperty("webdriver.chrome.driver", "Driver Path"); driver=new ChromeDriver(); driver.get("URL"); driver.manage().deleteAllCookies(); driver.manage().wind ...

What could be causing the async request with await to not properly wait for the response data?

I'm having trouble with the await function in my code, can anyone provide assistance? I've followed tutorials and copied the code exactly as shown but it still doesn't work. The CardsID array needs to be filled before I call console.log(Card ...

Tips for creating a pop-up window on an ASP.NET web form

I am looking to incorporate a popup window as a child of my primary asp.NET form. The popup window will allow users to input information using a dropdown list. When the popup window appears, it will take focus and disable the main window. ...

Unable to modify the chosen option within a select dropdown

I am trying to change the selected option of a select element using jQuery, but I can't seem to make it work. Here is the code I have: $("#ID option[value=grpValue]").prop('selected', 'selected').change(); If I manually type in a ...

A Guide on Adding Excel-Like Filtering Functionality to AngularJS

I am struggling to implement a simple Excel-like filter for a table using AngularJS (v.1). I have shared my code snippet below and would appreciate any help to show filtered data in the table after checking a checkbox and clicking on the OK button. I have ...

Access Denied: Phonegap Is Off Limits

I am in the process of developing an Android and iOS application. In order to accomplish this, I need to utilize cross-domain ajax requests since I am using Phonegap for development purposes. The issue I'm facing is as follows: when I access my server ...

How can you utilize jQuery's .post() method to send information as an object?

When I send a .post() request like this var data = $(this).serialize(); $('form').on('submit', function(event) { event.preventDefault(); $.post('server.php', data, function(data) { $('#data').append( ...

Is there a problem with the layout or indexing?

My website features a div that animates in using a jQuery click function, appearing over other divs that have animated in on $(document).ready(). Strangely, this div shows up behind the others only on the home page of my website and not on any other pages, ...

Picture disappearing following the refresh of an AJAX iframe

Currently, I am developing a profile system where the user's profile is displayed in an iframe that reloads when the form submit button is clicked. The content updates successfully upon reloading, but there is an issue with images not displaying after ...