I want to filter the received json so that in html only the author's name and the quotation itself will go away. The error in the filter itself, but what I can not understand.
Code:
$(document).ready(function(){ $("#getMessage").on("click", function(){ //получаю json $.getJSON("http://quotes.stormconsultancy.co.uk/random.json", function(json) { var html = ""; //фильтр var filtered = json.filter(function(val){ return val.author && val.quote; }); //перебираю данные и вывожу в html $.each(filtered, function(key, val){ html += "<div class = 'quote'>"; html += "<p> author: " + key + "</p>" + "<p>" + val + "</p>"; html += "</div>"; }); $('.message').html(html); }); }); });
filtermethod? Where did he come from? I can't find it in the jQuery API documentation - vihtor