Dano Dano - 3 years ago 202
jQuery Question

.val has no effect, and also .append has no effect

My code:

url: "{{URL::to('/announcement/get/fields')}}",
type: "post",
data: {id:id},
success: function (response) {

this.title = "n/a";
this.body = "n/a";

var self = this;

$.each( response, function( key, value ) {
self.title = response['aTitle'];
self.body = response['aBody'];

// CKEDITOR.instances[editEditor].insertText(this.body);
error: function(jqXHR, textStatus, errorThrown) {
console.log(textStatus, errorThrown);


response returns an array like this:

aTitle: value

aBody: announcement content

There is a
option in the form and once the user clicks on an announcement title, the values of that announcement should be inserted into the announcement title field and announcement body.

Value was working for few moments but somehow I broke it, and append wasn't working at all.

For the body
I have a
with CKeditor on it.

if I do
<textarea>Some text</textarea>
"Some text" will show in the
but if I append it with jquery nothing will show.


returns length 0, but
returns the length of the title so the variable isn't empty


I just noticed that I did not need the .each, my bad, so I did this


But it still doesn't work, yet if I do
it works.

Fixed the title, but the body still doesn't work.

Answer Source


  • don't need the each()
  • probably targeted #announcementEditTitle wrongly (maybe not an ID but a class? spelling?)
  • are using the wrong jQuery method to fill the Body, use val (or try text/html, but it should be val)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download