I have this link

I need to take names from this source, text and display on the page

I have no idea how to rip text from a third-party source. I will be grateful

    1 answer 1

    We use ajax with jsonp type.

    When receiving data, we process the received json object as we like. In this case, simply display the text in a div using the callback function.

     var url = 'https://api.vk.com/method/wall.getComments?owner_id=-30458160&post_id=24905&v=5.58'; $.ajax({ url: url, dataType: "jsonp", success: function( response ) { if (response && response.response.count > 0) { //console.log( response ); response.response.items.forEach(function(item, i, arr) { $('#response-text').append(item.text + '<br/><br/>'); }); } } }); 
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="response-text"></div> 


      var url = 'https://api.vk.com/method/wall.getComments?owner_id=-30458160&post_id=24905&v=5.58'; $.ajax({ url: url, dataType: "jsonp", success: callback }); function callback(response) { if (response && response.response.count > 0) { //console.log( response ); response.response.items.forEach(function(item, i, arr) { $('#response-text').append(item.text + '<br/><br/>'); }); } } 
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="response-text"></div> 


    And it is advisable to separate the url and the data that is passed to it when prompted. Those. the data will be in the data block Ajax request. Something like:

     ... url: 'https://api.vk.com/method/wall.getComments', data: { 'owner_id': '-30458160', 'post_id': '24905', 'v': '5.58' }, ... 
    • Thank you I noticed that you have to update to update the data. Is it possible to fix this somehow? - shadelete
    • @ endoneslife esessno. It is necessary to bind your logic - when this data is needed ........ If you click a button, then bind the request to the button, if every N-seconds, then to the timer, etc. - Alexey Shimansky