Unfortunately, this is instagram-side restriction. You should use therefore server-side queries. Browser blocks cross-domain request because in the return there is no Allow-origin header. I recommend to read more on CORS to fully understand this problem.
For example if you're using PHP backend, this is the solution:
Backend:
<?php
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL,"https://api.instagram.com/v1/media/" . $_REQUEST['id'] ."/likes?ACCESS_TOKEN=" .$_REQUEST['token']);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'out'.$_REQUEST['data']);
// grab URL and pass it to the browser
curl_exec($ch);
// close cURL resource, and free up system resources
curl_close($ch);
Frontend:
$.ajax({
url: "path.to.backend.php",
type: 'POST',
data: {
id:idslist[1],
token:accesstoken,
data:{}
},
success: function (result) {
alert("out" + result);
},
error: function () {
alert("error");
}
});