javascript - loading text in to textarea jquery -


i change value of textarea when button clicked, tried loading page using .load() getting [object object] in textarea instead of data php page. doing wrong here? want here have cancel , save button , there text loaded textarea via php when page loads if user clicks cancel want restore original text in textarea.

 <textarea class="trd" id="txt"><?php echo $row['text']; ?></textarea>   <button class="btn btn-default" id="cancel">cancel</button>  $('#cancel').click(function() {             var res = $('#txt').load('somedata.php');             $("#txt").val(res); 

you need use $.get() fetch contents of remote resource , using success callback assign result textarea

$('#cancel').click(function () {     $.get('somedata.php', function (res) {         $("#txt").val(res);     }) }); 

.load() return promise object, not contents of remote resource


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -