I don't know if I'm approaching this the correct way. I have a main page where I'm displaying some information. You can then click a button and the page will then display a form by loading the form from a separate file:

```
    $('#viewport').load('/views/myView.php #targetDiv')

```

This works fine. But this view is a form. I want to then submit the included form with Ajax as well. But I can't seem to do it. I think it is because if I set up a button handler for the form it doesn't work as the form isn't present when the main page and JQuery script is loaded.

So to be clear, I'm loading this div onto my main page using JQuery and Ajax load. I then want to simply submit this form with Ajax also.

```
<div id="targetDiv">
<div class="title">Submit News</div>
    <form role="form" id="submitMyForm">

        <div class="form-group">
            <label for="myInput">Input here</label>
            <input type="text" class="form-control" id="myInput">
        </div>

        <button type="button" id="subMyFormBtn" class="btn btn-default">Submit</button>    
    </form>        
</div> 

```

TIA

Full solution:

```
$('#viewport').load('/views/myView.php #targetDiv');
$("#targetDiv").live("submit",function(e){
    e.preventDefault();
    //ajax here
});

```