Manu Manu - 2 days ago 3
Javascript Question

I am having issue with handlebars. Its not compiling the data

I've shifted my server, Handlebar is working fine on my previous server. The same code is not working on my new linux server. Data is not being compile.

My json response is fine its returning data properly. Any guide please!

Code:

var $deferredsLocal = [];
$deferredsLocal[0] = $.ajax({ url: tabUrl, type: "POST"});
$deferredsLocal[1] = $.ajax({url: 'templates/tabs_contact_detail.html', type: "GET", cache: true});
$.when.apply(null, $deferredsLocal).then(function (json, htm) {
var htmls = htm[0];
var template = Handlebars.compile(htmls);
var completeHtml = template(json[0]);

$('#content').empty();
$('#content').html(completeHtml);

$('#content').find('td.question_label').each(function (index, element) {
$(this).html($('<div/>').html($(this).html()).text());
});
$("#preloader").hide();
});


// tabUrl is returning json response

Answer

Hi Guys there was json format issue. The data i was getting was looking into json format but it was not in json actually. I just moved the header: header('Content-Type: application/json'); up and placed it in the start of my code.

Comments