Как динамически отображать продукты с помощью jquery? - PullRequest
0 голосов
/ 25 сентября 2018

Я пытаюсь отобразить продукты на странице просмотра внешнего интерфейса с помощью jquery. Это ответ API:

"{"success":"1","product_data":[{"server_time":"2018-09-25 17:02:30","products_id":8,"products_quantity":9999,"products_model":"","products_image":"resources\/assets\/images\/product_images\/1502181584.pPOLO2-26008953_standard_v400.jpg","products_price":"125.50","products_date_added":"2017-08-08 08:39:44","products_last_modified":null,"products_date_available":null,"products_weight":"0.500","products_weight_unit":"kg","products_status":1,"products_tax_class_id":1,"manufacturers_id":null,"products_ordered":0,"products_liked":0,"low_limit":0,"is_feature":0,"products_slug":"slug","language_id":1,"products_name":"STANDARD FIT COTTON POPOVER","products_description":"Standard Fit: a comfortable, relaxed silhouette. If you favored our Classic Fit or Custom Fit, you will like this updated version.\r\nSize medium has a 30\" back body length.\r\nButton-down point collar. Buttoned half-placket.\r\nShort sleeves.\r\nLeft chest buttoned pocket.\r\nBox-pleated back yoke ensures a comfortable fit and a greater range of motion.\r\n100% cotton.\r\nMachine washable. Imported. Japanese fabric.\r\nModel is 6'1\"\/185 cm and wears a size medium.","products_url":null,"products_viewed":0,"manufacturers_name":null,"manufacturers_image":null,"date_added":null,"last_modified":null,"manufacturers_slug":null,"manufacturers_url":null,"discount_price":null,"categories_id":8,"categories_description_id":22,"categories_name":"Men Casual Shirts","images":[{"image":"resources\/assets\/images\/product_images\/1502182266.pPOLO2-26008953_alternate1_v360x480.jpg"},{"image":"resources\/assets\/images\/product_images\/1502182272.pPOLO2-26008953_alternate2_v360x480.jpg"},{"image":"resources\/assets\/images\/product_images\/1502182279.pPOLO2-26008953_alternate3_v360x480.jpg"}],"isLiked":"0","attributes":[{"option":{"id":4,"name":"Size"},"values":[{"id":29,"value":"Small","price":"0.00","price_prefix":"+"},{"id":32,"value":"Medium","price":"0.00","price_prefix":"+"}]}]},{"server_time":"2018-09-25 17:02:30","products_id":9,"products_quantity":9999,"products_model":"","products_image":"resources\/assets\/images\/product_images\/1502182426.pPOLO2-26008935_standard_v400.jpg","products_price":"89.50","products_date_added":"2017-08-08 08:53:46","products_last_modified":null,"products_date_available":null,"products_weight":"0.500","products_weight_unit":"kg","products_status":1,"products_tax_class_id":1,"manufacturers_id":null,"products_ordered":0,"products_liked":0,"low_limit":0,"is_feature":0,"products_slug":"slug","language_id":1,"products_name":"STANDARD FIT MADRAS POPOVER","products_description":"Standard Fit: a comfortable, relaxed silhouette. If you favored our Classic Fit or Custom Fit, you will like this updated version.\r\nSize medium has a 30\" body length.\r\nButton-down point collar. Three-button placket. Genuine mother-of-pearl buttons.\r\nShort sleeves. Left chest patch pocket.\r\nSplit back yoke with a box pleat ensures a comfortable fit and a greater range of motion.\r\nSignature embroidered pony at the left chest pocket.\r\n100% cotton. Machine washable. Imported.\r\nDue to the natural characteristics of this material, the coloring may rub off onto fabrics and upholstery.\r\nModel is 6'1\"\/185 cm and wears a size medium.","products_url":null,"products_viewed":0,"manufacturers_name":null,"manufacturers_image":null,"date_added":null,"last_modified":null,"manufacturers_slug":null,"manufacturers_url":null,"discount_price":null,"categories_id":8,"categories_description_id":22,"categories_name":"Men Casual Shirts","images":[{"image":"resources\/assets\/images\/product_images\/1502186424.pPOLO2-26008935_alternate1_v360x480.jpg"},{"image":"resources\/assets\/images\/product_images\/1502186446.pPOLO2-26008935_alternate2_v360x480.jpg"},{"image":"resources\/assets\/images\/product_images\/1502186468.pPOLO2-26008935_alternate3_v360x480.jpg"}],"isLiked":"0","attributes":[{"option":{"id":4,"name":"Size"},"values":[{"id":32,"value":"Medium","price":"0.00","price_prefix":"+"},{"id":35,"value":"Large","price":"0.00","price_prefix":"+"},{"id":38,"value":"Extra Large","price":"0.00","price_prefix":"+"}]}]},{"server_time":"2018-09-25 17:02:30","products_id":10,"products_quantity":9999,"products_model":"","products_image":"resources\/assets\/images\/product_images\/1502186978.pPOLO2-26315018_standard_v400.jpg","products_price":"165.00","products_date_added":"2017-08-08 10:09:38","products_last_modified":null,"products_date_available":null,"products_weight":"0.500","products_weight_unit":"kg","products_status":1,"products_tax_class_id":1,"manufacturers_id":null,"products_ordered":0,"products_liked":0,"low_limit":0,"is_feature":0,"products_slug":"slug","language_id":1,"products_name":"STANDARD FIT COTTON WORKSHIRT","products_description":"Standard Fit: a comfortable, relaxed silhouette. If you favored our Classic Fit or Custom Fit, you will like this updated version.\r\nSize medium has a 32\" body length, an 18\u00bd\" shoulder, a 46\u00bd\" chest, and a 35\" sleeve length. Sleeve length is taken from the center back of the neck and changes 1\" between sizes.\r\nPoint collar. Buttoned placket. Genuine mother-of-pearl buttons.\r\nLong sleeves with buttoned barrel cuffs.\r\nTwo chest buttoned pockets.\r\nSplit back yoke with a box pleat ensures a comfortable fit and a greater range of motion.\r\n100% cotton. Machine washable. Imported. Italian fabric.\r\nDyed with true indigo, which may rub off onto fabrics, leather, and upholstery.\r\nModel is 6'1\"\/185 cm and wears a size medium.","products_url":null,"products_viewed":0,"manufacturers_name":null,"manufacturers_image":null,"date_added":null,"last_modified":null,"manufacturers_slug":null,"manufacturers_url":null,"discount_price":null,"categories_id":8,"categories_description_id":22,"categories_name":"Men Casual Shirts","images":[{"image":"resources\/assets\/images\/product_images\/1502187573.pPOLO2-26315018_alternate1_v360x480.jpg"},{"image":"resources\/assets\/images\/product_images\/1502187583.pPOLO2-26315018_alternate2_v360x480.jpg"},{"image":"resources\/assets\/images\/product_images\/1502187596.pPOLO2-26315018_alternate3_v360x480.jpg"}],"isLiked":"0","attributes":[{"option":{"id":4,"name":"Size"},"values":[{"id":35,"value":"Large","price":"0.00","price_prefix":"+"},{"id":38,"value":"Extra Large","price":"0.00","price_prefix":"+"}]}]},{"server_time":"2018-09-25 17:02:30","products_id":11,"products_quantity":9999,"products_model":"","products_image":"resources\/assets\/images\/product_images\/1502187824.pPOLO2-26317497_standard_v400.jpg","products_price":"145.00","products_date_added":"2017-08-08 10:23:44","products_last_modified":null,"products_date_available":null,"products_weight":"0.500","products_weight_unit":"kg","products_status":1,"products_tax_class_id":1,"manufacturers_id":null,"products_ordered":0,"products_liked":0,"low_limit":0,"is_feature":0,"products_slug":"slug","language_id":1,"products_name":"ELDRIDGE SUPER SLIM JEAN","products_description":"Eldridge Super Slim: Polo's skinniest fit. Sits low at the waist. Trim through the thigh and the leg. Tapered leg opening.\r\nSize 32W has an 8\u00be\" rise and a 12\u00bd\" leg opening.\r\nBelt loops. Zip fly with our signature shank closure.\r\nFive-pocket styling with signature metal rivets. \"Polo\" label at the coin pocket.\r\n\"Polo Ralph Lauren\" leather patch at the back right waist.\r\n94% cotton, 4% polyester, 2% elastane.\r\nMachine washable. Imported.\r\nDue to the natural characteristics of this material, the coloring may rub off onto fabrics and upholstery.\r\nModel is 6'1\"\/185 cm and wears a size 32W x 32L.","products_url":null,"products_viewed":0,"manufacturers_name":null,"manufacturers_image":null,"date_added":null,"last_modified":null,"manufacturers_slug":null,"manufacturers_url":null,"discount_price":null,"categories_id":9,"categories_description_id":25,"categories_name":"Men Jeans","images":[{"image":"resources\/assets\/images\/product_images\/1502188797.pPOLO2-26317497_alternate1_v360x480.jpg"},{"image":"resources\/assets\/images\/product_images\/1502188805.pPOLO2-26317497_alternate2_v360x480.jpg"},{"image":"resources\/assets\/images\/product_images\/1502188814.pPOLO2-26317497_alternate3_v360x480.jpg"}],"isLiked":"0","attributes":[{"option":{"id":7,"name":"Waist"},"values":[{"id":41,"value":"28W","price":"0.00","price_prefix":"+"},{"id":42,"value":"30W","price":"0.00","price_prefix":"+"},{"id":43,"value":"32W","price":"0.00","price_prefix":"+"}]},{"option":{"id":10,"name":"Length"},"values":[{"id":65,"value":"30L","price":"0.00","price_prefix":"+"},{"id":66,"value":"32L","price":"0.00","price_prefix":"+"}]}]},{"server_time":"2018-09-25 17:02:30","products_id":12,"products_quantity":9999,"products_model":"","products_image":"resources\/assets\/images\/product_images\/1502189779.pPOLO2-26316198_standard_v360x480.jpg","products_price":"165.00","products_date_added":"2017-08-08 10:56:19","products_last_modified":null,"products_date_available":null,"products_weight":"0.500","products_weight_unit":"kg","products_status":1,"products_tax_class_id":1,"manufacturers_id":null,"products_ordered":0,"products_liked":0,"low_limit":0,"is_feature":0,"products_slug":"slug","language_id":1,"products_name":"SULLIVAN SLIM FIT JEAN","products_description":"Sullivan Slim: sits slightly below the waist. Slim, tapered leg.\r\nSize 32W has a 9\" rise and a 14\" leg opening.\r\nBelt loops. Zip fly with our signature shank closure.\r\nFive-pocket styling with signature metal rivets. \"Polo\" label at the coin pocket.\r\n\"Polo Ralph Lauren\"\u2013debossed leather patch at the back right waist.\r\n97% cotton, 3% elastane.\r\nMachine washable. Imported.\r\nDue to the natural characteristics of this material, the coloring may rub off onto fabrics and upholstery.\r\nModel is 6'1\"\/185 cm and wears a size 32W x 32L.","products_url":null,"products_viewed":0,"manufacturers_name":null,"manufacturers_image":null,"date_added":null,"last_modified":null,"manufacturers_slug":null,"manufacturers_url":null,"discount_price":null,"categories_id":9,"categories_description_id":25,"categories_name":"Men Jeans","images":[{"image":"resources\/assets\/images\/product_images\/1502189793.pPOLO2-26316198_alternate1_v360x480.jpg"},{"image":"resources\/assets\/images\/product_images\/1502189798.pPOLO2-26316198_alternate2_v360x480.jpg"},{"image":"resources\/assets\/images\/product_images\/1502189805.pPOLO2-26316198_alternate3_v360x480.jpg"}],"isLiked":"0","attributes":[{"option":{"id":1,"name":"Colors"},"values":[{"id":1,"value":"Brown","price":"0.00","price_prefix":"+"},{"id":3,"value":"Blue","price":"0.00","price_prefix":"+"}]},{"option":{"id":7,"name":"Waist"},"values":[{"id":44,"value":"34W","price":"0.00","price_prefix":"+"},{"id":45,"value":"36W","price":"0.00","price_prefix":"+"},{"id":46,"value":"38W","price":"0.00","price_prefix":"+"},{"id":47,"value":"40W","price":"0.00","price_prefix":"+"}]},{"option":{"id":10,"name":"Length"},"values":[{"id":65,"value":"30L","price":"0.00","price_prefix":"+"},{"id":66,"value":"32L","price":"0.00","price_prefix":"+"},{"id":67,"value":"34L","price":"0.00","price_prefix":"+"}]}]},{"server_time":"2018-09-25 17:02:30","products_id":13,"products_quantity":9999,"products_model":"","products_image":"resources\/assets\/images\/product_images\/1502190187.pPOLO2-26315541_standard_v400.jpg","products_price":"125.00","products_date_added":"2017-08-08 11:03:07","products_last_modified":null,"products_date_available":null,"products_weight":"0.500","products_weight_unit":"kg","products_status":1,"products_tax_class_id":1,"manufacturers_id":null,"products_ordered":0,"products_liked":0,"low_limit":0,"is_feature":0,"products_slug":"slug","language_id":1,"products_name":"HAMPTON STRAIGHT FIT JEAN","products_description":"Hampton Straight: Polo's most relaxed fit. Sits slightly below the waist. Easy fit through the thigh and slightly tapered at the ankle.\r\nSize 32W has a 9\" rise and a 16\" leg opening.\r\nBelt loops. Button fly with our signature shank closure.\r\nFive-pocket styling with signature metal rivets. \"Polo\" label at the coin pocket.\r\n\"Polo Ralph Lauren\"\u2013debossed leather patch at the back right waist.\r\n100% cotton.\r\nMachine washable. Imported.\r\nDue to the natural characteristics of this material, the coloring may rub off onto fabrics and upholstery.\r\nModel is 6'1\"\/185 cm and wears a size 32W x 32L.","products_url":null,"products_viewed":0,"manufacturers_name":null,"manufacturers_image":null,"date_added":null,"last_modified":null,"manufacturers_slug":null,"manufacturers_url":null,"discount_price":null,"categories_id":9,"categories_description_id":25,"categories_name":"Men Jeans","images":[{"image":"resources\/assets\/images\/product_images\/1502190279.pPOLO2-26315541_alternate1_v360x480.jpg"},{"image":"resources\/assets\/images\/product_images\/1502190286.pPOLO2-26315541_alternate2_v360x480.jpg"},{"image":"resources\/assets\/images\/product_images\/1502190295.pPOLO2-26315541_alternate3_v360x480.jpg"}],"isLiked":"0","attributes":[{"option":{"id":7,"name":"Waist"},"values":[{"id":41,"value":"28W","price":"0.00","price_prefix":"+"},{"id":42,"value":"30W","price":"0.00","price_prefix":"+"}]},{"option":{"id":10,"name":"Length"},"values":[{"id":65,"value":"30L","price":"0.00","price_prefix":"+"},{"id":67,"value":"34L","price":"0.00","price_prefix":"+"}]}]},{"server_time":"2018-09-25 17:02:30","products_id":14,"products_quantity":9999,"products_model":"","products_image":"resources\/assets\/images\/product_images\/1502190590.pPOLO2-26404754_standard_v400.jpg","products_price":"90.00","products_date_added":"2017-08-08 11:09:50","products_last_modified":null,"products_date_available":null,"products_weight":"0.500","products_weight_unit":"kg","products_status":1,"products_tax_class_id":1,"manufacturers_id":null,"products_ordered":0,"products_liked":0,"low_limit":0,"is_feature":0,"products_slug":"slug","language_id":1,"products_name":"LAXMAN TECH SUEDE SNEAKER","products_description":"Rounded toe. Lace-up front.\r\nWoven tag with our signature pony at the tongue.\r\nPadded velvet insole.\r\nTreaded rubber outsole.\r\n\"Polo\" printed at the outer side.\r\nUpper: man-made materials.\r\nMesh panels: 100% nylon.\r\nImported.","products_url":null,"products_viewed":0,"manufacturers_name":null,"manufacturers_image":null,"date_added":null,"last_modified":null,"manufacturers_slug":null,"manufacturers_url":null,"discount_price":null,"categories_id":10,"categories_description_id":28,"categories_name":"Men Shoes","images":[{"image":"resources\/assets\/images\/product_images\/1502190650.pPOLO2-26404754_standard_v400.jpg"},{"image":"resources\/assets\/images\/product_images\/1502190660.pPOLO2-26404754_alternate2_v360x480.jpg"},{"image":"resources\/assets\/images\/product_images\/1502190665.pPOLO2-26404754_alternate3_v360x480.jpg"}],"isLiked":"0","attributes":[{"option":{"id":4,"name":"Size"},"values":[{"id":74,"value":"7D","price":"0.00","price_prefix":"+"},{"id":75,"value":"8D","price":"0.00","price_prefix":"+"},{"id":76,"value":"8.5D","price":"0.00","price_prefix":"+"},{"id":77,"value":"9D","price":"0.00","price_prefix":"+"}]}]},{"server_time":"2018-09-25 17:02:30","products_id":15,"products_quantity":9999,"products_model":"","products_image":"resources\/assets\/images\/product_images\/1502191191.pPOLO2-26256326_standard_v400.jpg","products_price":"69.50","products_date_added":"2017-08-08 11:19:51","products_last_modified":null,"products_date_available":null,"products_weight":"0.500","products_weight_unit":"kg","products_status":1,"products_tax_class_id":1,"manufacturers_id":null,"products_ordered":0,"products_liked":0,"low_limit":0,"is_feature":0,"products_slug":"slug","language_id":1,"products_name":"VAUGHN SUEDE SLIP-ON SNEAKER","products_description":"Fits true to size.\r\nRounded toe. Slip-on styling.\r\nElasticized side gores.\r\n\"Polo\" tag at the outer side. Padded collar.\r\nSignature pony\u2013debossed suede heel.\r\nPadded canvas insole.\r\nTreaded rubber outsole.\r\nLeather.\r\nImported.","products_url":null,"products_viewed":0,"manufacturers_name":null,"manufacturers_image":null,"date_added":null,"last_modified":null,"manufacturers_slug":null,"manufacturers_url":null,"discount_price":null,"categories_id":10,"categories_description_id":28,"categories_name":"Men Shoes","images":[{"image":"resources\/assets\/images\/product_images\/1502191226.pPOLO2-26256326_alternate1_v360x480.jpg"},{"image":"resources\/assets\/images\/product_images\/1502191230.pPOLO2-26256326_alternate2_v360x480.jpg"},{"image":"resources\/assets\/images\/product_images\/1502191234.pPOLO2-26256326_alternate3_v360x480.jpg"}],"isLiked":"0","attributes":[{"option":{"id":4,"name":"Size"},"values":[{"id":76,"value":"8.5D","price":"0.00","price_prefix":"+"}]}]},{"server_time":"2018-09-25 17:02:30","products_id":16,"products_quantity":9999,"products_model":"","products_image":"resources\/assets\/images\/product_images\/1502191373.pPOLO2-21857429_standard_v400.jpg","products_price":"175.00","products_date_added":"2017-08-08 11:22:53","products_last_modified":null,"products_date_available":null,"products_weight":"0.500","products_weight_unit":"kg","products_status":1,"products_tax_class_id":0,"manufacturers_id":null,"products_ordered":0,"products_liked":0,"low_limit":0,"is_feature":0,"products_slug":"slug","language_id":1,"products_name":"WORKINGTON LEATHER DRIVER","products_description":"Penny tab at the vamp.\r\nSingle-needle stitching at the toe.\r\nPadded leather insole.\r\nLeather outsole with rubber-nub detailing.\r\nDebossed \"Polo\" tag at the outer side.\r\nLeather.\r\nImported.","products_url":null,"products_viewed":0,"manufacturers_name":null,"manufacturers_image":null,"date_added":null,"last_modified":null,"manufacturers_slug":null,"manufacturers_url":null,"discount_price":null,"categories_id":10,"categories_description_id":28,"categories_name":"Men Shoes","images":[{"image":"resources\/assets\/images\/product_images\/1502191401.pPOLO2-21857429_alternate2_v360x480.jpg"},{"image":"resources\/assets\/images\/product_images\/1502191406.pPOLO2-21857429_alternate3_v360x480.jpg"}],"isLiked":"0","attributes":[{"option":{"id":4,"name":"Size"},"values":[{"id":75,"value":"8D","price":"0.00","price_prefix":"+"},{"id":76,"value":"8.5D","price":"0.00","price_prefix":"+"},{"id":77,"value":"9D","price":"0.00","price_prefix":"+"}]}]},{"server_time":"2018-09-25 17:02:30","products_id":17,"products_quantity":9999,"products_model":"","products_image":"resources\/assets\/images\/product_images\/1502191568.pPOLO2-26256404_standard_v400.jpg","products_price":"275.00","products_date_added":"2017-08-08 11:26:08","products_last_modified":null,"products_date_available":null,"products_weight":"0.500","products_weight_unit":"kg","products_status":1,"products_tax_class_id":1,"manufacturers_id":null,"products_ordered":0,"products_liked":0,"low_limit":0,"is_feature":0,"products_slug":"slug","language_id":1,"products_name":"DILLIAN II SUEDE CHELSEA BOOT","products_description":"Fits true to size.\r\n\u00bd\"\/15 mm heel height.\r\nRounded toe.\r\nElasticized gores at the sides.\r\nPull tab at the heel.\r\nLeather insole.\r\nLeather outsole with rubber treads.\r\nLeather.\r\nImported.","products_url":null,"products_viewed":0,"manufacturers_name":null,"manufacturers_image":null,"date_added":null,"last_modified":null,"manufacturers_slug":null,"manufacturers_url":null,"discount_price":null,"categories_id":10,"categories_description_id":28,"categories_name":"Men Shoes","images":[{"image":"resources\/assets\/images\/product_images\/1502191619.pPOLO2-26256404_alternate1_v360x480.jpg"},{"image":"resources\/assets\/images\/product_images\/1502191626.pPOLO2-26256404_alternate2_v360x480.jpg"},{"image":"resources\/assets\/images\/product_images\/1502191633.pPOLO2-26256404_alternate3_v360x480.jpg"}],"isLiked":"0","attributes":[{"option":{"id":1,"name":"Colors"},"values":[{"id":5,"value":"Black","price":"0.00","price_prefix":"+"}]},{"option":{"id":4,"name":"Size"},"values":[{"id":74,"value":"7D","price":"0.00","price_prefix":"+"},{"id":75,"value":"8D","price":"0.00","price_prefix":"+"}]}]}],"message":"Returned all products.","total_record":75}
"

//retrieving data from api

<script type="text/javascript">

		//	alert("submitted!");
			
			$(function() {
		 
		 // var customers_firstname=$("#customers_firstname").val();
       // var customers_lastname=$("#customers_lastname").val();
       //  var customers_telephone=$("#customers_telephone").val();
          //var email=$("#email").val();
		  
		 var prod=$('#products');
		var d = new Date();
    var consumer_nonce = d.getTime();
		
		//U=url+'api/getallproducts';
		//alert(consumer_nonce);
		//exit;
		//var ul="{{ url('/backend/api/save_reg') }}";
	
		  $.ajax({
        type:"POST",
        url:url+'api/getallproducts',
      // data:$("#postcontent").serialize(),
		data:{
			    language_id:1,
			    type:'most liked',
				 page_number:1,
			  
			   },
			    headers: {
        
        "consumer-key": consumer_key, 
		"consumer-secret": consumer_secret, 
		"consumer-nonce": consumer_nonce, 
		"consumer-device-id": consumer_device_id,  
    },
success:function(response){ 
		console.log(response);
		
		
		$.each(response,function(i,response){
			///

			
			
			});

	   //alert(response);
    
 

//-- alert(response[1]); 
            //alert(response);
			//response = response.toJSON();
			//alert(response);
          //  $("#return_update_msg").html(response); 
            //$(".post_submitting").fadeOut(1000);                
        }
    });
	  
    });
			
			
		
</script>
<!--- this is static design of the product. i would like to use jquery each loop -->
<div class="ltabs-items-inner ltabs-slider">
<ul id="products">
</ul>


<div class="row">
 <div class="ltabs-item">
 <div class="col-md-12">
 
    <div class="item-inner product-layout transition product-grid">
      <div class="product-item-container">
      
        <div class="left-block">
          <div class="product-image-container second_img"> <a href="#!" target="_self" title="Pastrami bacon"> <img src="{{ asset('public/frontend/qshopee')}}/image/catalog/demo/product/270/1.jpg" class="img-1 img-responsive" alt="Pastrami bacon"> <img src="{{ asset('public/frontend/qshopee')}}/image/catalog/demo/product/270/12.jpg" class="img-2 img-responsive" alt="Pastrami bacon"> </a> </div>
          <div class="button-group so-quickview cartinfo--left">
            <button type="button" class="addToCart btn-button" title="Add to cart" onClick="cart.add('60 ');"> <i class="fa fa-shopping-basket"></i> <span>Add to cart </span> </button>
            <button type="button" class="wishlist btn-button" title="Add to Wish List" onClick="wishlist.add('60');"><i class="fa fa-heart"></i><span>Add to Wish List</span> </button>
            <button type="button" class="compare btn-button" title="Compare this Product " onClick="compare.add('60');"><i class="fa fa-refresh"></i><span>Compare this Product</span> </button>
            <!--quickview--> 
            <a class="iframe-link btn-button quickview quickview_handler visible-lg" href="quickview.html" title="Quick view" data-fancybox-type="iframe"><i class="fa fa-eye"></i><span>Quick view</span></a> 
            <!--end quickview--> 
          </div>
        </div>
        <div class="right-block">
          <div class="caption">
            <div class="rating"> <span class="fa fa-stack"><i class="fa fa-star fa-stack-2x"></i></span> <span class="fa fa-stack"><i class="fa fa-star fa-stack-2x"></i></span> <span class="fa fa-stack"><i class="fa fa-star fa-stack-2x"></i></span> <span class="fa fa-stack"><i class="fa fa-star fa-stack-2x"></i></span> <span class="fa fa-stack"><i class="fa fa-star-o fa-stack-2x"></i></span> </div>
            <h4><a href="#!" title="Pastrami bacon" target="_self">Pastrami bacon</a></h4>
            <div class="price">$42.00</div>
          </div>
        </div>
      </div>
    </div>
  
    </div>
    
  </div>
  </div>

  

</div>

1 Ответ

0 голосов
/ 25 сентября 2018

Я изменил ваш код, чтобы вы могли начать получать данные правильно;Затем вам нужно будет отформатировать HTML каждого продукта, чтобы добавить его в контейнер:

//	alert("submitted!");

$(function () {

// var customers_firstname=$("#customers_firstname").val();
// var customers_lastname=$("#customers_lastname").val();
//  var customers_telephone=$("#customers_telephone").val();
//var email=$("#email").val();

var prod = $('#products');
var d = new Date();
var consumer_nonce = d.getTime();

//U=url+'api/getallproducts';
//alert(consumer_nonce);
//exit;
//var ul="{{ url('/backend/api/save_reg') }}";

$.ajax({
	type: "POST",
	url: url + 'api/getallproducts',
	// data:$("#postcontent").serialize(),
	data: {
		language_id: 1,
		type: 'most liked',
		page_number: 1,

	},
	headers: {

		"consumer-key": consumer_key,
		"consumer-secret": consumer_secret,
		"consumer-nonce": consumer_nonce,
		"consumer-device-id": consumer_device_id,
	},
	success: function (response) {
		console.log(response);

		// I'm changing these lines:
		if(typeof response === 'string') {
			response = JSON.parse(response);
		}
		var productData = response.product_data;
		$.each(productData, function (i, product) {

			// Now you have in product all the attributes, like products_name or products_id
			console.log('Product name:', product.products_name);

			// Now you can append your row to #prod
			prod.append(/* your parsed template */);

			// Where parsed template will be a string that cointains your HTML template but with dinamic data that you filled with the different product attributes!
		});

		//alert(response);


		//-- alert(response[1]); 
		//alert(response);
		//response = response.toJSON();
		//alert(response);
		//  $("#return_update_msg").html(response); 
		//$(".post_submitting").fadeOut(1000);                
	}
});

});
...