我有以下带有 json 数据类型的 ajax 调用和响应。目前我直接在js中编写数据和html标签,但我认为这不好且难以阅读。如何在 Codeigniter 视图中传递它们?
$.ajax({
type: "POST",
url: baseUrl + "profile/setting",
dataType: 'json',
success: function(data){
var html = "";
html += "<div>";
html += "<img src=\"" + baseUrl + data.picture + "\" />";
html += "<div>" + data.email + "</div>";
html += "<div>" + data.first_name + " " + data.last_name + "</div>";
html += "<div>" + data.address + "</div>";
html += "<div><input type=\"text\" class=\"input_text_top\"/></div>";
html += "<div><input type=\"text\" class=\"input_text_middle\"/></div>";
html += "<div><input type=\"text\" class=\"input_text_bottom\"/></div>";
html += "<div><input type=\"submit\" class=\"btn btn_grey\"/></div>";
html += "</div>";
$('#result_column').removeAttr('style').html(data);
}
});