Here is the javascript code that has a "no" in the datastring and i want to pass that datastring to data.php using getJson So that in the end i can get json as a response. My data.php code is working but javascript code is not working so please help me.
Javascript code
dataString = 'no='+ no;
$.getJSON("data.php", dataString,function(response){
console.log(response);
});
php code
$no=$_POST['no'];
$headers = array(
'Content-Type: application/json',
);
$url = 'https://www.outpan.com/api/get-product.php?barcode='.$no.'&apikey=318c91a99b132a29dda536d63e7fb8b4';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
curl_close($ch);
//$result_arr = json_decode($result, true);
echo result;