I'm trying to call a file through ajax which has a javascript function in it. I'm able to get the contents of the file (when I alert it it shows everything written in that file) but I don't know how to call the function in the file.

My code is:
To call ajax to run that function:

```
if($("#essentialbtn").click(function() {
    $.ajax("essentialplan.php").done(function(data) {
       alert(data);
    });
}));

```

File: (named essentialplan.php)

```
<script type="text/javascript">
    localStorage.setItem('essentialPlan', $('#essential').text());     
    localStorage.setItem('essentialPrice', $('#priceA').text());

    window.location.href = "http://incrediblewebpages-com.stackstaging.com/convertion%20bubble/conversion2.php"; 
</script>

```