I am trying to pass my variables from my main page to external JS file. Please see my code.

**Main page:**

```
<script type="text/javaScript">
$(document).ready(function(){

var add_project_link="<?= base_url().'add_project/show_form'; ?>";
var add_agent_link="<?= base_url().'agent/add_agent';?>";
});

</script>

```

**External JS**

```
 $(document).ready(function(){
    alert(add_project_link);
    alert(add_agent_link);
  });

```

I got:

> 
> uncaught referenceError add\_project\_link is not defined. 
> 
> 
> 

I thought the external JS would catch the variable declared in main page. Any thoughts? Thanks a lot!