How to display app data on Shopify product page using AJAX in jQuery

To get data from your app in Shopify, foremost, you need to include jQuery. Here is an example of how to perform this task.get data in shopify using custom app

Step 1 Paste the below code to include jQuery
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
Step 2 Start jQuery code now. or paste the below code. jQuery(document).ready(function(){ jQuery.ajax({ //code here }); });

Step 3 In code section we just need to pass 3 things. The first thing is URL from where data is coming , second on success run the success block and third error, on getting error run the error block.

url: "https://www.example.com/function?shop="+Shopify.shop+"&productid="+meta.product.id,

success: function(response) {
alert("success");
console.log(response);
}

error:function(msg)
        {
          console.log(msg);
          
        }
Here is the complete code below now.
jQuery(document).ready(function(){
  
  jQuery.ajax({

url: "https://www.example.com/function?shop="+Shopify.shop+"&productid="+meta.product.id,

success: function(response) {
alert("success");
console.log(response);
}

error:function(msg)
        {
          console.log(msg);
          
        }

 }); });

Note: Please note that here is an example that how to get data. To perform it at your end, you need to make changes according to your app code. Like www.example.com/function, here you pass those things where you have code and receive data in your app. Otherwise, this code will not work if you completely copy it.

get data in shopify using custom appexpoundsofttechsolutionget data in shopify using custom app