If this is a redundant question please let me know and point me there, but I am not finding the exact question/answer combination nor a mixture of the two.
I have some ajax in jquery that calls a function from a php page. Without the handlebars the json data comes back nice and pretty. No issues there. However I can't seem to get ajax to write out my results to a handlebars template. Here is the code I have now:
$.ajax({
type: "post",
url: "../includes/db_functions.inc.php",
data: ({ p : p, p2 : p2, f : f }),
dataType: "json",
success: function(results){
$.each(results, function(i, item){
var context = [
{
id : item[i].id,
clock_number : item[i].clock_number,
}
],
template = Handlebars.compile( $('#template').html() );
$('table.entries').append( template(context) );
});
}
});
anyone know what I might be missing here? I 99% sure its in the context area, but just not finding it.
[edit]
<table class="entries">
<script id="template" type="text/x-handlebars-template">
<tr>
<td>{{id}}</td>
<td>{{clock_number}}</td>
</tr>
</script>
</table>