Question: A word before my question to say I am pretty new to OOP in PHP, and I'm very grateful to the site, and you all for reading - and sometimes answering beautifully (as you can see [here](https://stackoverflow.com/questions/5596895/php-database-class) or [here](https://stackoverflow.com/questions/5622605/php-getting-a-reference-through-a-constructor), or even [here](https://stackoverflow.com/questions/4907018/building-a-factory-in-php)) and helping big time my late (sort of) improvement dealing with classes. 

All my previous questions lead me today to this one:  

**In a class extending PDOStatement, how can I trigger a default action each time one of the parent public methods is called?** 

I can do this:

```
class genc_query extends PDOStatement{
  public function rowCount(){
    $this->myDefaultAction();
    return parent::rowCount();
  }
}

```

But as I need to change in the same way almost all of the native methods, I wonder if there's no way to trigger a function like \_\_call() as if these methods were private (as it's not possible to make them private).

Answer: 
Add this to the button.

```
onclick="this.disabled=true;"

```

Example:

```
<input type="submit" onclick="this.disabled=true;" />

```
Your solution has two parts. First, you want to disable the "Upload" button.

```
<form ... onSubmit="document.getElementById('fileThing').disabled = true;">
...
<input type="FILE" id="fileThing" size="40">
...
</form>

```

You can add the JavaScript part before any other JS that you might be running in that block (such as calling the AJAX script).

Next, you will need to put some code into your AJAX script that enables the button. The exact location will vary. I will assume that your AJAX script calls a function called `whenComplete` when it receives the full response from the server. Add the following line into that function, along with any other after-request processing code:

```
document.getElementById('filething').disabled = false;

```

You will need to figure out where exactly this line needs to go, as we can't know how your AJAX script is set up without seeing the implementation itself.