daily pastebin goal
59%
SHARE
TWEET

Untitled

a guest Feb 20th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [
  2.     {"name":"Silver","price":525,"per_month":"20","first_invoice":"20"},
  3.     {"name":"Gold","price":500,"per_month":"50","first_invoice":"0"},
  4.     {"name":"Avion","price":750,"per_month":"10","first_invoice":"10"}
  5. ]
  6.    
  7. //send get request
  8.     $.get(
  9.         url,
  10.         { 'dst': dst, 'price':price },
  11.         function(data) {
  12.  
  13.             var objects = jQuery.parseJSON(data);
  14.  
  15.             var items = [];
  16.  
  17.             jQuery.each(objects, function(){
  18.                 console.log(this);
  19.  
  20.                 items.push('<li id="' + this.name + '">' + this.price + '</li>');
  21.             });
  22.  
  23.             jQuery('<ul/>', {
  24.                 'class': 'my-new-list',
  25.                 html: items.join('')
  26.             }).appendTo('#results');                
  27.         }
  28.     );
  29.    
  30. jQuery('<ul/>', {
  31.                 'class': 'my-new-list',
  32.                 html: items.join('')
  33.             }).appendTo(jQuery('body').find('#results'));
  34.    
  35. var objects = jQuery.parseJSON(data);
  36.  
  37. var items = '';
  38.  
  39. jQuery.each(objects, function(){
  40.     items += '<li id="' + this.name + '">' + this.price + '</li>';
  41. });
  42.  
  43. jQuery('<ul/>', {
  44.     'class': 'my-new-list'
  45. }).html(items).appendTo('#results');
  46.    
  47. //replace the $('iframe') with ID/class selector if possible
  48. jQuery('iframe').contents().find('#results').append(jQuery('<ul/>', {
  49.     'class': 'my-new-list'
  50. }).html(items));
  51.    
  52. $('<ul>')
  53.     .addClass('my-new-list')
  54.     .html($.map(objects, function(el) {
  55.         return '<li id="' + el.name + '">' + el.price + '</li>';
  56.     }).join("n"))
  57.     .appendTo('#results');
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top