Output ajax data to your template

Output ajax data to your template

AgaradAgarad Posts: 12Questions: 0Answers: 0

Hello there! Please help! Output data from Excel using PHPExcel in this layout (php echo):

<tr class="product__element">
<td>' . $row['1'] . '</td>
<td>' . $row['2'] . '</td>
<td><a data-fancybox="images" data-caption="' . $row['3'] . '" href="i/' . $row['7'] . '.webp"><img loading="lazy" class="product__img" src="i/' . $row['7'] . '.webp" alt="' . $row['3'] . ' texttexttext" title="' . $row['3'] . '" ></a></td>
<td class="product__name">' . $row['3'] . '</td>
<td>' . $row['4'] . '</td>
<td>' . $row['5'] . '</td>
<td class="product__price">' . $row['6'] . '</td>
<td><div class="product__quantity"></div></td>
<td><button class="product__add-to-cart-button" data-sb-id-or-vendor-code="' . $row['0'] . '" data-sb-product-name="' . $row['3'] . '" data-sb-product-price="' . $row['6'] . '" data-sb-product-quantity="1" data-sb-product-img="i/' . $row['7'] . '.webp"><i class="fas fa-cart-plus"></i></button></td>
</tr>

But this is a slow decision. Please tell me how to do this using Ajax?
Ajax data:

[
"a01634", // $row['0']
"\u0421\u0430\u043c\u043e\u0440\u0435\u0437\u044b", // $row['1']
"\u0421\u0430\u043c\u043e\u0440\u0435\u0437\u044b \u043a\u0440\u043e\u0432\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u0446\u0438\u043d\u043a\u043e\u0432\u0430\u043d\u043d\u044b\u0435 6,3 \u043c\u043c", // $row['2']
"\u0421\u0430\u043c\u043e\u0440\u0435\u0437\u044b \u043a\u0440\u043e\u0432\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u0446\u0438\u043d\u043a\u043e\u0432\u0430\u043d\u043d\u044b\u0435 6.3\u0445175", // $row['3']
"6.3\u0445175", // $row['4']
"\u0448\u0442.", // $row['5']
"9.8", // $row['6']
"gvozdiershenye" // $row['7']
]

The most appropriate one was: https://editor.datatables.net/examples/simple/template-attribute and https://datatables.net/forums/discussion/43514 however, the example did not help me understand what to do in my case - some columns should display data from several database fields. Strings (TR) must be of the "product__element"class.

Replies

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.