0

I am trying to implement a "post request get" pattern for SEO reasons. Therefore I want to pass values via jquery post to a php file which then returns a url that will be used for a get 302 redirect.

How could I access the values "prg=..." from the link inside the jquery function in order to pass it to the php script?

<script type="text/javascript">
   $(function() {
       $('.redir-link[prg]').click(function (e) {
          request = $.ajax({
             url: "/app_global/prg.php",
             type: "post",
             data: {
                url: 'test',
                url2: 'url2'
             },
            success: function (response) {
                console.log("Hooray, it worked!"+response+this.prg);
                window.location = response
            },

       });
   });

</script>



<a prg="val-1|val2" class="redir-link" title="test">PRG Link test</a>
merlin
  • 2,717
  • 3
  • 29
  • 59
  • 1
    The duplicate is even a duplicate of this: http://stackoverflow.com/questions/7859558/this-doesnt-work-in-a-function – mplungjan Nov 02 '16 at 09:11
  • 1
    Also do `data-prg="val-1|val2" ` and later after storing `$self = $(this)`do `+$self.data("prg")` – mplungjan Nov 02 '16 at 09:13

0 Answers0