Answers for "jquery add to array with key"

1

jquery add to array with key

var obj = {};

$.getJSON("displayjson.php",function (data) {
    $.each(data.news, function (i, news) {
        obj[news.title] = news.link;
    });                      
});

// later:
$.each(obj, function (index, value) {
    alert( index + ' : ' + value );
});
Posted by: Guest on July-10-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language