How to call a class by clicking the button

Asked

Viewed 487 times

1

i have a php class that accesses the database to check if the user is registered, I wanted that when I click on the "Log in" button that this class was called, I saw some related topics but were confused, and did not help me! And another question I would have to use Jquery, PHP or Javascript, which would be the easiest and practice?

1 answer

1


I believe a language client-side is easier and practical...

example:

<input type="button" name="button_name" onclick="exemploF()" value="Chama class">

Jquery

function exemploF() {
      $.post( 
          'exemplo.php'
       ).success(function(resp){
            json = $.parseJSON(resp);
            alert(json);
       });
}

example.php

$class = new suaClass();
$method =  $class->umaFunction();
echo json_encode($method);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.