how to Call a specific method of my Web Service from java script?

醉酒当歌 提交于 2019-12-25 04:59:24

问题


i am trying to call a web service from my pure HTML page using java script. i had successfully created a web service using java on net beans. now i want to call a method from that web service using java script with sending some parameters to the web Service, i had tried so far but not succeed yet. i had successfully called the method using jsp page, but i need to do it by using simple html page.

i had seen an example Here but it is not working with me. :(

can you please give me some example, so that i come to know how to call a specific method of my web service from java script with sending some parameters to the web service.

thanks in advance.

EDIT

my script

    function validateForm(frm)
{ 
document.forms[0].action="http://localhost:8084/Web_Service_Example/CircleFunctions?"
document.forms[0].method="post"
document.forms[0].submit()
}

my CircleFunctions method

public class CircleFunctions {
public int sum()

{
    int a = 20;
    int b = 40;

    int c = a+b;

    return c;
}
}

回答1:


document.forms[0].action="http://localhost:8080/webservice/services/add"
document.forms[0].method="get"
document.forms[0].submit()


来源:https://stackoverflow.com/questions/10477163/how-to-call-a-specific-method-of-my-web-service-from-java-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!