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: enter image description here

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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -