<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready( function () { //The page has been loaded...
var ref = document.referrer; //Referrer
var curpg = document.location.href; //Current page URL
var dataSet = 'ref=' + ref + '&curpg=' curpg + '&shizz1e=21';
$.ajax({
type: "GET",
url: "http://www.domainname.com/ajaxreceiver.php",
data: dataSet
});
return false;
});
</script>
I am trying to submit the ‘curpg’, ‘ref’, and ‘shizz1e’ variables to ajaxreceiver.php as soon as the page loads, without any user intervention. I am also trying to avoid having the page refresh or redirect the client to ajaxreceiver.php. I’m not sure why this code isn’t working; the dataSet variable never gets sent to ajaxreceiver.php.
I would have to see your server-side PHP code because your JavaScript code looks OK to me. I think it should work.
Try this rewriting it like this, though:
This is just a bit cleaner in my opinion. Please show some of your server-side PHP code, so I can really help you find out what’s going wrong.