Reputation:
I am using jQuery tempalte in my project and now i found that a thing not worked i not know what's goes wrong in my code.
can anyone show me where i am goes wrong.
<script id="ajaxresult" type="text/html">
<li>
<h3>
<a href="{{= url}}">{{= title}}</a></h3>
<p>{{= content}}</p>
<div class="url">{{= url}}</div>
</li>
</script>
var title = $("#txtsrch").val();
var resp = GetAjaxResponse("/home/blah", { topic: title, pagenum: fpage + 1 });
$("#ajaxresult").render(JSON.parse(resp)).appendTo("#result ul");
fpage = fpage + 1;
when i try this code i found that i got the error render is not a function
can anyone show me where my code have a bug or any other good way i can use to do this thing
Upvotes: 1
Views: 429
Reputation: 98786
For a start, you seem to have pasted HTML code directly into your <script>
tag, and put your JavaScript outside of the <script>
tag.
<script>
tags can only contain JavaScript. At a guess, I’d say your HTML code should look more like this:
<ul id="ajaxresult">
<li>
<h3><a href="{{= url}}">{{= title}}</a></h3>
<p>{{= content}}</p>
<div class="url">{{= url}}</div>
</li>
</ul>
I’ve no idea what’s going on in your JavaScript though. As Calum asked in his comment, which part of jQuery are you trying to use?
Upvotes: 2