I have a function called `search` and it is called through either a div being clicked or a form being submitted.

When the div is clicked, the `id` of it is send as data through the AJAX call. However what I want to do is if the form is submitted, send the inputted data through the AJAX call.

I thought about having two functions and AJAX calls, however I feel this is unnecessary and there must be a simple solution. 

```
<div id="12" class="question"></div>
<div id="24" class="question"></div>
<div id="11" class="question"></div>

<form id="question" method="post">
<input type="text" name="enter" id="enter">
<input type="submit">
</form>

<script>
$(".question").click(search);
$("form#question").submit(search);

function search() {
   $.ajax({
      type: "POST",
      url: "sending.php",
      data: "example=" + this.id,
      success: function(data) {
         console.log(data);
      }
   });
}
</script>

```