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

  • SEARCH
  • Home
  • 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 4625138
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:13:46+00:00 2026-05-22T03:13:46+00:00

I have some variable: <input type=text id=use /> <div id=app></div> I want if ajax

  • 0

I have some variable:

<input type="text" id="use" />
<div id="app"></div>

I want if ajax success i want to send $('#use').val() into <div>.
I have try like below:

 success: function(){
                      $("#app").val($("#use").val());
                      }

then:

$("#app").text($("#use").val());

and:

$("#app").replacewith($("#use").val());

But, i get no result. Could you tell me how to do this?


$("#enter").click(function(){
     if($("#passlog").valid()){
     var params = $("#passlog").serialize();
     $.ajax({
              type:"post",
              url:"process3.php",
              data:params,
              cache:false,
              async:false,
              success: function(res){
                            switch(parseInt(res)){
                                   case "1":     //i get value 1 from server side if get 1 do the job below
                                           $("#app").text($("#use").val());
                                           break;
                                           }
                             },
              });
         }
    });
  • 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-05-22T03:13:47+00:00Added an answer on May 22, 2026 at 3:13 am

    Divs do not have values, instead you set their HTML:

    $("#app").html($("#use").val());
    

    Or their text:

    $("#app").text($("#use").val());
    

    It’s also worth nothing though that allowing someone to directly enter code into the DOM of your website is a very bad idea.


    I noticed you have an extra comma after the success call on your AJAX, try removing it as that could be causing an issue.

    If text() is not working you may have an issue with your AJAX. Do you have an error handler? If not try adding one like the below, and let us know what you get back.

    $.ajax({
        type:"post",
        url:"process3.php",
        data:params,
        cache:false,
        async:false,
        success: function(res){
            switch(parseInt(res)){
                case "1":     //i get value 1 from server side if get 1 do the job below
                    $("#app").text($("#use").val());
                    break;
            }
        },
        error:function (xhr, ajaxOptions, thrownError){
            alert(xhr.status);
            alert(thrownError);
        }
    });
    

    }

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some text that is stored in a variable like this: <div class=foo>text
I have this form: <form name=form method=post> <div> <p> Problem Name: <input type=text size=20
I have string value and Type of some variable (For example int and 32
I have a long snippet of HTML I want some javascript variable to equal
I have a variable that im define with another variable and some text. $title
I have some jquery that inputs text into a database and then clears the
I have some jQuery that takes the value of a text input and puts
I have some colors that seem to come from a Delphi TColor variable (e.g
I would like to have a function that modifies some variable list of parameters
Let's suppose I have n arrays, where n is a variable (some number greater

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.