1
でただ一つの製品からJSONデータを取得する:私はコレクションのページグリッド内の製品をクリックすると、やろうとして何イムshopify
、私は、Ajaxを使用してなど、製品のタイトルを取得しようとしています。
HERESに私のコード:
{% for product in collection.products %}
<div class="product">
{% capture producturl %}{{ product.url }}{% endcapture %}
<a class="ajax ajax{% increment ajaxno %}">
PRODUCT IMAGE
</a>
</div>
<script>
jQuery(function ($) {
$("a.ajax0").click(function(){
jQuery.getJSON('{{ producturl }}.js', function(product) {
console.log('The title of this product is ' + product.title);
});
});
});
</script>
{% endfor%}
が、私はイムは、現在のページ上のすべての製品のアラートを取得し、任意の製品をクリックしてください。 私がクリックしている製品のタイトルだけを取得するためにコードを調整するにはどうすればよいですか?
おかげでたくさん。どちらも私のために働く – wsgg