$.ajax({
url: 'db_employer_info_lookup.php',
type: 'POST',
dataType: 'json'
}).done(function(data) {
// console.log(data.employee_info[0].length);
for (var i = 0; i < data.employee_info[0].length; i++) {
if(i%2 == 0){
$('#the-team-wrapper .flex-content').append('<div class="employee-profile-pic flex-item" data-img-src="'
+data.employee_info[0][i]['profile_pic']+'"></div><div class="employee-bio-wrapper flex-item"><h2>'
+data.employee_info[0][i]['firstname']+" "+data.employee_info[0][i]['lastname']+'</h2>'+$('<h3 />')
.html(get_job_title(data.employee_info[0][i]['id']))+'<p>'+data.employee_info[0][i]['bio']+
'</p></div>');
}else {
$('#the-team-wrapper .flex-content').append('<div class="employee-bio-wrapper flex-item"><h2>'
+data.employee_info[0][i]['firstname']+" "+data.employee_info[0][i]['lastname']+'</h2>'+**$('<h3 />')
.html(get_job_title(data.employee_info[0][i]['id']))**+'<p>'+data.employee_info[0][i]['bio']
+'</p></div><div class="employee-profile-pic flex-item" data-img-src="'
+data.employee_info[0][i]['profile_pic']+'"></div>');
}
var profile_pic_path = data.employee_info[0][i]['profile_pic'].split('\\').join('\\\\');
$("#the-team-wrapper .flex-content-wrapper .flex-content .employee-profile-pic:eq("+i+")")
.css({'background': 'url(_employee_pics/'+profile_pic_path+')',
'background-repeat': 'no-repeat','background-position': 'center', 'background-size': 'cover'});
}
});
var get_job_title = function(employee_id){
$.ajax({
url: 'db_job_title_lookup.php',
type: 'POST',
dataType: 'text',
data:{
employee_id: employee_id
}
}).done(function(data1){
data1;
});
};
Hi, I have this code where I'm retrieving some data from the server using Ajax in the 'var get_job_title' function. Now I want to use that text in an H3 element as seen in the code above the 'var get_job_title' function but all I get back is [object Object]. Any help please!!!
' + yourvar + '
....')`? You're already stuffing a ton of html into there with plain string operations, so what's the mental block keeping you from doing the same with the h3? – Marc B Oct 05 '16 at 18:23