when I click on product title then I want to get product id and then post product id to another URL and get related product id from the database.
<script>
var a = window.location.href;
$.ajax({
type: "GET",
dataType: "json",
success: function (data) {
var id = data.product.id;
console.log(id);// i got product id but how i post this id to another url and get related product id from database.
}
});
Do this:
<script>
var a = window.location.href;
$.ajax({
type: "GET",
dataType: "json",
success: function (data) {
var id = data.product.id;
$.post("{{url('productIdApi')}}", {product_id: id}, function(result){
//do whatever after response returns
});
}
});