1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

call a function from a link

Discussion in 'General PHP and MySQL Discussions' started by asma, Dec 27, 2015.

  1. asma

    asma Member

    i already have a xen:callback that runs the function on page load. i want to add a link where the user clicks it to re run the function as many times as he likes

    function loadMore()
    echo "look a new line! <br/>";

    then in my template
    <a href="???">Magic!</a>

    it will call the function

    can this be done?
  2. Daniel Hood

    Daniel Hood Well-Known Member

    <a href="#" onclick="loadMore();">Magic!</a>
  3. asma

    asma Member

    didn't work :(
    i tried this also didn't work :(
    <a href="#" onclick="{xen:callback class='my_php_file' method='loadMore'}">Magic!</a>
  4. Daniel Hood

    Daniel Hood Well-Known Member

    Oh, yeah. That's not how that works at all. The callback tag is to render content from php. You need to trigger Javascript that makes an Ajax request to the php.

Share This Page