Nebi
Nebi

Reputation: 57

pass parameter with out page reload php

I want to access php id on the same page for this i want something like this:

<a onclick='showDialog_update()' href='follow_event.php?id=$customer->id'\"> 

but i want to show popup and not want the page to get refresh so i can show my result on my popup on the same page. i already tried this jquery code but its not working for me

<a href="javascirpt:void(0)" rel='$customer->id' class="showpopup">

$(".showpopup").click(function(ev)
{   
  var getid = $(this).attr('rel');
  alert(getid); 
  ev.preventDefault();
}

Upvotes: 0

Views: 58

Answers (1)

Mikołaj Woźniak
Mikołaj Woźniak

Reputation: 113

Please try this code.

You must echo the php variable into the a tag

<a href="javascript:void(0)" rel='<?php echo $customer->id; ?>' class="showpopup">asdf</a>
    <!-- jQuery cdn source, can be skipped -->
    <script
        src="https://code.jquery.com/jquery-1.12.4.min.js"
        integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ="
        crossorigin="anonymous"></script>

<script>
     $(
        $(".showpopup").click(function(ev)
        {
            var getid = $(this).attr('rel');
            alert(getid);
            ev.preventDefault();
        })
     );

</script>

Upvotes: 1

Related Questions