using ajax with handlebars in node.js

2019-08-09 07:14发布

问题:

I have a file call item.handlebars, and it can be render using res.render('item').

The file look like this

<h1>{{title}}</h1>
<script>
//jquery events and manipulation
</script>

Now I want to load that template file with ajax. How do I do that? Do I need to include handlebarjs in client side?

I tried to do an ajax call to the endpoint and this is what I got in the response

You must pass a string or Handlebars AST to Handlebars.compile. You passed [object Object]