使用ajax调用类方法php


Invoke class method php using ajax

这是我的例子:

class test {
function tester(){
    do something;
}
}

我需要检查在ajax如果按钮被点击:

echo "<button name='"updateList'" type='"button'">&#8635; Update the List</button>";

如果是,使用ajax,我需要调用测试方法

$(document).ready(function(){
    $("button").click(function(){
      $.ajax({url:"index.php",
          type: "post",
          data: {action: 'updateList'}
          }); 
      });   
    });

我需要一些提示或帮助如何做到这一点,我想这样做,因为我不希望我的页面刷新按钮后点击

//index.php
if(isset($_POST['action']&&$_POST['action']=='updatelist'){
    $test = new Test();
    $test->tester();
}