Set wysiwyg's value with javascript
The following code worked perfectly fine for me,

(function($) {
    $(document).ready(function() {
      $("#edit-body-und-0-value").val('this is a test content.');
    });
})(jQuery);


I have placed this code is test.js file. 'edit-body-und-0-value' is the ID of the textarea.

I have installed WYSIWYG module and placed CKEditor under sites/all/libraries/ckeditor folder. Although it doesn't matter if you are using CKEditor or any other editor because we are mainly referring to ID of our textarea.