External js function in jsp

Asked

Viewed 464 times

1

Hello,

I intend to use an external js Function, a js typeahead, and call it in my jsp input, but it’s not working accordingly.

Js import to my jsp.

<script src="javascript/todospaises.js" type="text"></script> 

As for the Html code, the input, which has to receive the js Function.

@Html

<input type="text" id="input-paises" class="typeahead" placeholder="Países">

And, the Function code of the external js, ie of another file.

var $input = $("#input-paises");
                        $input.typeahead({source:[‘Brasil, Estados Unidos, Inglaterra, Alemanha’,
                        ]});

However, typeahead does not work when the Function of another js is used. Function is only effective when it is in the same jsp,

<script> var $input = $("#input-paises"); $input.typeahead({source:[‘Brasil, Estados Unidos, Inglaterra, Alemanha’, ]}); <script>

That is, only when it is in jsp. Only when the snippet of js code is in jsp.

Thank you!

  • On the JSP generated page, when you click on "View Source" and click on the external JS file reference, what happens? Gives 404 error or opens JS normally?

  • @Rafaelb., open normally.

  • @All, Any tips for the same?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.