Last active
December 27, 2015 20:29
-
-
Save Chitrank-Dixit/7384508 to your computer and use it in GitHub Desktop.
get JSON data from any url in knockoutjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// write this snippet inside the Knockout viewModel | |
// getting all the comments from the server | |
$.getJSON("comments.php", function(commentModels) { | |
var t = $.map(commentModels.comments, function(item) { | |
return new Comment(item); | |
}); | |
self.comments(t); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment