Q:

Unable to insert ajax returned data into input field

The Ajax Request
$.ajax({
    type: "GET",
    url: "http://localhost/CI2/index.php/login/testfunc",
    data: {macro: selectedmacro},
    async: false,
    success: function (data) {
        $('#tinyeditor').val(data);
        $('#p2').html(data);
    }
});

PHP
echo "This is a test";

HTML
<p id = 'p2'>fer</p>
<input type = "text" id = "tinyeditor" />

What Works:
$('#p2').html(data); works and replaces "fer" with "This is a test" 
$('#tinyeditor').val('data'); also works and inserts "data" string into the input field
The Problem
$('#tinyeditor').val(data); fails to insert "This is a test" into the input field.  The field remains blank. 

A:

First parse the data using JSON.parse(data) and try to insert.