javascript - How correctly append data to HTML from jQuery and Ajax? -
i working on implementing "load more articles" functionality using python, flask , ajax. working server-side don't know how append new data html using jquery.
i have following json object sent server side:
and following jquery , ajax code in html template:
<script type=text/javascript> $(function() { $('a#get-more').bind('click', function() { $.getjson($script_root + '/_get_the_data_from_serverside', { }, function(data) { $("#more").append(data.stories[0].storycontent); }); return false; }); }); </script> <span id=more></span> <a href="#" id=get-more></a>
but doesn't work can see, data json object "storycontent" not being appended html.
any ideas?
the path json should data[0].storycontent. so:
<script type=text/javascript> $(function() { $('a#get-more').bind('click', function() { $.getjson($script_root + '/_get_the_data_from_serverside', { }, function(data) { $("#more").append(data[0].storycontent); }); return false; }); }); </script> <span id="more"></span> <a href="#" id=get-more></a>
Comments
Post a Comment