javascript - JQuery - Change $_GET variable on button click -


i'm trying create series of buttons update website's $_get['year'] variable. want buttons work on these pages:

  • example.com
  • example.com/?search=foo
  • example.com/?search=foo&year=2015.

so example if clicked on <a>2016</a> 'year' tag updated year=2016 , webpage show search results or year. i've tried using jquery ajax so:

                <ul class="dropdown-menu datedropdown">                     <li><a>2016</a></li>                     <li><a>2015</a></li>                     <li><a>2014</a></li>                 </ul>               <script>                 $(document).ready(function () {                     $(".datedropdown>li>a").each(function() {                         $(this).click(function() {                             alert("pressed");                             $.get({                               url: "index.php",                               data: $(this).html(),                               callback: alert("sent")                             });                         ;})                     ;})                 ;}             </script> 

currently i'm getting "pressed" , "sent" alert, webpage not updating. figured work using window.location , regex change or add 'year' uri, way neater. ideas?

take @ jquery.get params.

in situation, like:

$(".datedropdown>li>a").each(function(index,elem){     $(elem).click(function(){         alert('pressed');         $.get('url', {search:'foo', year: $(this).text() }).done( function(){ alert('done!')} )     }) }) 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -