Murali Kumar Murali Kumar - 1 year ago 71
Ajax Question

Unable to insert ajax returned data into input field

The Ajax Request

type: "GET",
url: "http://localhost/CI2/index.php/login/testfunc",
data: {macro: selectedmacro},
async: false,
success: function (data) {


echo "This is a test";


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

What Works:

works and replaces "fer" with "This is a test"

also works and inserts "data" string into the input field

The Problem

fails to insert "This is a test" into the input field. The field remains blank.

Sam Sam
Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download