I want to display some text on a text area upon a response from an ajax request.
<div id="wrapper">
<div id="menu">
<p class="welcome">Welcome, <b></b> <%=session.getAttribute( "username" )%> </p>
</div>
<!-- This div will contain the chatlog. -->
<div id="chatbox"></div>
<form name="message" action="" method="post">
<input name="usermsg" type="text" id="usermsg" size="63" />
<input name="submitmsg" type="submit" id="submitmsg" value="Send" />
</form>
</div>
I want to set 'chatbox' text within an ajax request response. This is the css document for chatbox
#chatbox {
text-align:left;
margin:0 auto;
margin-bottom:25px;
padding:10px;
background:#fff;
height:270px;
width:430px;
border:1px solid #ACD8F0;
overflow:auto; }
This is the ajax call
function loadLog(){
$.ajax({
type: "GET",
url: "HandleMessage",
//contentType: "application/json",
/*data: {
card: JSON.stringify(card)
},*/
success: function(response) {
if(response != null)
{
$("#chatbox").attr("value", "aa"); // I want to concat current value and response here
}
//document.getElementById('chatbox').value = 'fff';
//alert(response);
},
error: function(data) {
alert('errorr');
}
});
Tried many things, but didn't work.
Tried,
$("#chatbox").attr("value", response);
$("#chatbox).val(response);
$(".chatbox").html(response);