daily pastebin goal
67%
SHARE
TWEET

Untitled

a guest Jan 17th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. success: function(data){
  2.             var toAppend = '';
  3.             if(typeof data === "object"){
  4.                 for(var i=0;i<data.length;i++){
  5.                     toAppend += '<tr><td colspan="2">'+data[i]['main-asin'][0]+'</td></tr>';
  6.                     toAppend += '<tr><td>'+data[i]['sub-asin'][0]+'</td><td></td></tr>';
  7.                 }
  8.                 $('.data-results').append(toAppend);
  9.             }
  10.         }
  11.    
  12. foreach($xml->Items->Item as $item){
  13.     $items_from_amazon[] = array('main-asin'=>$item->ASIN);
  14.     foreach($xml->Items->Item->Variations->Item as $item){
  15.         $items_from_amazon[] = array('sub-asin'=>$item->ASIN);
  16.     }
  17. }
  18.  
  19. echo json_encode($items_from_amazon); //return amazon products
  20.    
  21. toAppend += '<tr><td colspan="2">'+data[0]['main-asin'][0]+'</td></tr>';
  22. for(var i = 1; i<data.length; i++){
  23.   toAppend += '<tr><td>'+data[i]['sub-asin'][0]+'</td><td></td></tr>';
  24. }
  25.    
  26. PHP:
  27.  
  28. foreach($xml->Items->Item as $item){
  29.   $new_item_from_amazon = array(
  30.     'main-asin' => $item->ASIN,
  31.     'sub-asin'  => array(),
  32.   );
  33.   foreach($xml->Items->Item->Variations->Item as $item) {
  34.     $new_item_from_amazon['sub_asin'][] = $item->ASIN;
  35.   }
  36.   $items_from_amazon[] = $new_item_from_amazon;
  37. }
  38.  
  39. JS:
  40.  
  41. toAppend += '<tr><td colspan="2">'+data['main-asin']+'</td></tr>';
  42. for (var i = 0, l = data['sub-asin'].length; i < l; i++){
  43.   toAppend += '<tr><td>'+data['sub-asin'][i]+'</td><td></td></tr>';
  44. }
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