Reputation: 8385
I have the following code that works in conjunction with a "value" that is given from data inputted into an input
box.
How would I alter this code to just send the data - product_details['id']
without the need for input
data?
Example jQuery Code:
$('body').on("click", "#product_change_set_order_btn", function (e) {
e.preventDefault();
var box = $("#product_set_order_box");
var id = box.data("id");
var url = box.data("url");
var data_array = {
id : id,
new_sort : box.val(),
};
if($.trim(box.val()) != "")
{
ajaxCall(url, data_array, null, "product_set_order");
alert("Your Sort Order Has Been Set");
}
});
HTML Button:
<a href="#" class="btn btn-danger" title="Delete <?php echo $product_details['name']; ?>" data-name="<?php echo $product_details['name']; ?>" data-id="<?php echo $product_details['id']; ?>" data-url="admin/PS_products/ajax_product_delete">Delete <?php echo $product_details['name']; ?></a>
Upvotes: 0
Views: 128
Reputation: 16015
$('body').on("click", "#product_change_set_order_btn", function (e) {
e.preventDefault();
var box = $("#product_set_order_box");
var id = box.data("id");
var url = box.data("url");
var data_array = {
id : id,
new_sort : box.val(),
};
ajaxCall(url, data_array, null, "product_set_order");
alert("Your Sort Order Has Been Set");
});
Upvotes: 1