I am trying to get some data through the database in jquery. I doing this through ajax, the ajax code returns the value fine. I then set a variable with the data comment
.
The comment variable is then used to insert html into an element. However, it would appear that this variable is not set, because it is not being passed through the ajax function. How do I achieve that?
$(document).on('click', '.customer_progress_edit', function(){
timeline_id = $(this).attr('data-timeline');
$.ajax({
type : 'POST',
url : '//'+base_url+'/ajax2/timeline-comment.php',
data : 'timeline_id='+timeline_id,
success : function(data) {
comment = data;
}
});
$('#customer_pop_edit_comment').val(comment);
});
Yes, I am aware I could simply have the html() function within the ajax function, but I have simplified the code to give an easier idea of what I am trying to achieve, there is more to it than just this.