How to call a class by clicking the button

1

I have a class in php that accesses the database to check if the user is registered, I wanted that when I clicked the "Enter" button that this class was called, I saw some related topics but they were confused, and They did not help me! And another doubt would I have to use Jquery, PHP or Javascript, which would be the easiest and most practical?

    
asked by anonymous 24.10.2016 / 03:23

1 answer

1

I believe that client-side language is easier and more practical ...

example:

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

Jquery

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

example.php

$class = new suaClass();
$method =  $class->umaFunction();
echo json_encode($method);
    
24.10.2016 / 03:49