If you want all the code to be jQuery-style:
$.ajax({
method: 'POST',
url: 'getTemplate?templateID=' + str,
dataType: 'json'
}).done(function(data) {
$(data).each(function() {
$("#messageBody").html(this.templateBody);
$("#emailSubject").val(this.templateSubject);
});
});
solved Convert AJAX script to jQuery syntax [closed]