'Get value back to page without refreshing and pass it to a VAR

I want to update a url and pass it to the same page without refreshing the page. At the same time i then want the page to read the VAR again and update it. I need the PHP to use the var in the url on same page to read data in other classes im using. My page name is varydates.php and i need to get the year from a dropdown box. I had look at this code but its not working. Im kind new to jquery with php.

$("#year_select").change(function() {
var link = $(this).val();
var newUrl = '<?php echo base_url(); ?>'varydates.php&ampyr_select="+link;

$.ajax({
    type:"POST",
    url:"<?php echo base_url(); ?>varydates.php&ampyr_select="+link,
    data: { newlink: link },
    success:function(data){
        alert(data);
    }
  });
});



<?php $link=$_GET['newlink'];?>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source