so, I have an API for my topsite which I give to my users to put on their pages.
API:
<script type="text/javascript">
var id = 21;
$(document).ready(function(){
$.getJSON("http://topsite.com/index.php?page=vote", { id: id, hasVoted: 'unknown' }, function(data) {
if(data == 2) {
window.location.replace("http://topsite.com/index.php?page=vote&id=" + id);
}
});
});
So, basically what I want to do is avoid my customers to put this code on their site:
<script type="text/javascript">$.getJSON("http://topsite.com/index.php?page=vote&id=21");</script>
Because I want the users to get redirected to my site so I can earn some money from ads and even show them some information.
So, I want to know if there is any way to know when an ajax request is being used to access the site, or if there is a way to disable AJAX requests if the hasVoted parameter is set.
Any help is appreciated, thanks!
EDIT: I'll send custom headers when redirecting from site with 'hasVoted' parameter to other page.
QUESTION FOR EDIT: how would I go on about sending custom header with Location? Or am I way off here?