JSFiddle - React, Tailwind, and code Playground

by wisegorilla

JavaScript

$('#sync').click(function() {
	get_all_customers(0);

	function get_all_customers(since_id) {
		$.ajax({
			type: 'POST',
			data: {
				topic: 'customers',
				limit: $('#ApiLimit').val(), // Second add quotes on the value.
				since_id: since_id,
				hmac: shopify_verify.hmac,
				locale: shopify_verify.locale,
				session: shopify_verify.session,
				shop: shopify_verify.shop,
				timestamp: shopify_verify.timestamp
			},
			url: 'ajax-handler.php',
			dataType: "JSON", // data type expected from server
			success: function(data) {

				console.log(data);
				if (data.since_id != null) {
					get_all_customers(data.since_id);
				} else {
					console.log('Done');
				}
			},
			error: function(error) {
				console.log('Error: ' + error);
			}
		});
	}
});