How can I load an article (textarea) dynamically writing in the input text field (article ID) ? I want to check the ID in my DB and load the articles associated to it. Can you people give me an example ?
2 Answers
Use ajax if possible.
<textarea id="id_name"></textarea>
<script>
jQuery(function(){
jQuery.ajax({
url: "content_page.jsp", // .php or whatever file you are using
method: "GET",
success: function(data){
jQuery("textarea#id_name").val(data);
}
});
});
</script>
2 Comments
TruthTeller
@k.k what if the data displayed in the text area derives from a input text field ?
Krishna Kumar
you need populate data into same page or from other page?
An improved Version
<textarea id="id_name"></textarea>
<script>
$(document).ready(function(){
$.ajax({
url: "content_page.php",
method: "GET",
success: function(data){
$("textarea#id_name").val(data);
}
});
});
</script>
More reading about this http://api.jquery.com/ready/
2 Comments
callumacrae
Really? I always thought that calling the jQuery object with a function was just an alias for
$(document).ready.Deepak
@CallumMacrae My apologize !! I thought if the order is mixed we are in trouble!!