Reputation: 31
I have two separate java and javascript file. I want to call a method which is in my java class from my javascript function. Can anyone help me please ?
Upvotes: 1
Views: 642
Reputation: 261
I'm not sure what the structure of your code looks like but you cannot call a java method directly from javascript. You would need to use something that can map your URL to the method you are calling. You would need to make a servlet
or JSP
and use an ajax call to communicate to the server and call your desired method.
The following tutorial should help you get started writing something like this:
https://netbeans.org/kb/docs/web/ajax-quickstart.html
Upvotes: 1