Reputation: 35
I'm trying to update a textarea on my webpage when a form is submitted without refreshing the whole page. I've tried using AJAX like this:
$("#db_info").load(document.location.href + ' #db_info');
but when I submit the form, instead of just updating the text in the textarea, it creates a new nested text area inside of it, and causing it to appear blank. How can I update the textarea without reloading the page completely?
Edit: I figured it out finally. What I used is:
$.get("", function(data){
document.getElementById("db_info").innerHTML = $(data).find('#db_info').html();
});
Upvotes: 0
Views: 2895
Reputation: 690
I didn't really understand your question but if you want to change the value of a textarea
you should do this:
$("textarea#textareaid").val(value);
Upvotes: 3