0

I need to call the java method inside the jquery code. How to do that?

I tried by calling java.type, but it is not working. how to pass browser input to the backend java code give some examples var generate = function () {

    var activeTab = $("ul#CronGenTabs li.active a").prop("id");
    var results = "";
    switch (activeTab) {
        case "MinutesTab":
          //  results = "0 0/" + $("#MinutesInput").val() + " * 1/1 * ? *";
          results = Java.type(util.txt.cronGenerator.dailyAtHourAndMinute(MinutesInput))
            break;
3
  • Use an Ajax method to call a servlet Commented Apr 22, 2019 at 8:19
  • What is Java.type ? Commented Apr 22, 2019 at 8:24
  • If this method only converts a number to a cron-compatible string, you could rewrite it in Javascript. Commented Apr 22, 2019 at 8:25

1 Answer 1

0

In jquery Api you need to do ajax call to invoke your java method.In your case may be yo write a separate method that will make a call to the java method and call in in place of result.

    $.ajax({
    url: "/yourmethodName",
    type: "GET",//method type
    data: "your data, // the data you are sending
    success: function(response){ 
        //handle returned arrayList  //fetch the response to get yoyr data
    },
    error: function(e){  
        //handle error
    } 
});
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.