Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7873841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:37:53+00:00 2026-06-03T02:37:53+00:00

I wanted to refresh a div when a user submits a simple form. However

  • 0

I wanted to refresh a div when a user submits a simple form. However I can’t seem to find out why it’s not working. (It’s my first time using JQuery and Ajax)

My Script:

 <script src="static/jquery.js"></script> 
        <script>
                $('#submit_div').click(function(){
                    var data: $("#name").val();
                    var datastr: 'name='+data;
                    $.ajax{
                        type: "POST",
                        url: $(this),
                        data: datastr,
                        success: function(data){
                            $("#content").replaceWith($('#content'),$(data));
                            }
                    }
                });

        </script>

My HTML:

<div id="content">
          <div id="form_div">
            <form method="POST">
                <div id="form"> 
                    <div id="name_div"> name <input type="text" id="name" name="name"/></div>
                    <div id="submit_div">  <button type="submit" id="submit" name="submit">submit</button></div>
                </div>
            </form>
 <div style="clear:both;"></div></div>             

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T02:37:55+00:00Added an answer on June 3, 2026 at 2:37 am

    Errors

    var data: $("#name").val();
    var datastr: 'name='+data;
    $.ajax{...}
    $("#content").replaceWith($('#content'),$(data));
    

    Fixed

    $('#submit_div').click(function(e){
        e.preventDefault();                
        var data = $("#name").val();
        var datastr='name='+data;
        $.ajax({
            type: "POST",
            url: $(this),
            data: datastr,
            success: function(data){
                $("#content").replaceWith(data);
            }
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form built in ASP.NET. The first control allows the user to
I wanted to check whether the variable is defined or not. For example, the
I am currently playing around with x86 assembler since I wanted to refresh my
I wanted to ask if anyone knows how to move map from one div
I've just read about how WCF can send reliable messages and I wanted to
I try to do some simple Ajax call with refresh of page content with
I wanted to know how to refresh a ListActivity when I change/add data to
I am trying to refresh the div that contains a table that show the
I wanted to not reload the page every click of a sub-gallery. So I
I'm using a location.reload() with JQUERY to refresh when a user changes language. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.