jquery - Server side data to client side. (Node.js + express) -


good evening. we're starting implement server side code @ school , it's confusing hell. have piece of code on client side .js links server side .js. server side contains array of 2 objects. i'm trying pull length of array through client side. i've tried postscontroller.all.length , other things no avail. clues?

var postscontroller = {  all: function() {   $.get('/api/posts', function(data) {     var allposts = data;      // iterate through allposts     _.each(allposts, function(post) {       // pass each post object through template , append view       var $posthtml = $(postscontroller.template(post));       $('#post-list').append($posthtml);     });     // add event-handlers phrases updating/deleting     postscontroller.addeventhandlers();   }); }, 

i think problem not receiving json data server, instead jquery interpreting text. recommend trying use:

$.getjson() 

see more information here on jquery documentation site


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -