Display data in Rich Textarea on (ajax success) in javascript?

96 views Asked by At

Here My Code:


<textarea 
 class="textarea" id="about_us" placeholder="Place some text here"
 style="width: 100%; height: 100%; font-size: 14px; line-height: 18px; border: 1px solid #dddddd; padding: 10px;"
>
</textarea >

And My JavaSript code is I Recieve Data But Only Rich Textarea us not showing See This RichTextarea Image

<script>

$(document).ready(function () {
$(document).on('click', '.editbtn', function(){  
          var Pedit_id = $(this).attr("id");  
          $.ajax({  
               url:"../fetch/editproduct.php",  
               method:"POST",  
               data:{Pedit_id:Pedit_id},  
               dataType:"json",  
               success:function(data){ 
                    $('#about_us').val(data.product_dec);

               }  
          });  
     });
});
</script>

Please tell me where I mistake because I want to get data from MySQL database using ajax on button click and show to specific textarea please solve this . Regards Ahsan Javed

2

There are 2 answers

0
Dhruv Shah On BEST ANSWER

You are trying to set the value data.product_dec in element with id about_us. Since you are using Jquery I would suggest using .val() method of JQuery to achieve the desired outcome.

Refer:

Update:

$(document).ready(function () {
$(document).on('click', '.editbtn', function(){  
          var Pedit_id = $(this).attr("id");  
          $.ajax({  
               url:"/fetch/editproduct",  
               method:"POST",  
               data:{Pedit_id:Pedit_id},  
               dataType:"json",  
               success:function(data){ 
                    $('#about_us').val(data.product_dec);

               }  
          });  
     });
});
0
Luqman On

The url is probably the problem.If you are sending to a php document the add the extension:

url : "../fetch/editproduct.php",

And then the success function, the product_dec is not a method.I am not sure what you are trying to do there but make it:

$('#about_us').val(data+"product_dec");