Here following the working code,
$.get(ghost.url.api("posts", {
"tag:'Category Name'"
})).done(function(data) {
$.each(data.posts, function(i, post) {
console.log(post);
});
});
Now I want to add a variable there for the Category Name
So I used the following code,
var cat_name = "test";
$.get(ghost.url.api("posts", {
"tag:'+cat_name'"
})).done(function(data) {
$.each(data.posts, function(i, post) {
console.log(post);
});
});
But I am getting syntax error! How to resolve that? Where is my fault in that syntax?