Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
94
rated 0 times [  98] [ 4]  / answers: 1 / hits: 105150  / 11 Years ago, thu, january 30, 2014, 12:00:00

I have a webservice which will return a value. Here my requirement is, I need to call that webservice from an index.html page, that page have an html submit button. On that button click I am calling a JavaScript. From there I want to call the web method. how can I achieve this.



My webservice is localhost/ws/service.asmx; and web method is HelloWorld



 <input type=button value=Submit id=btn_submit onclick =return fun()>

function fun() {


// here I want to call the helloworld method.
return true;
}

More From » jquery

 Answers
20

Use jQuery for performin POST or GET request from your html page like this :



function fun() 
{
var data=hello;
$.get(http://localhost/ws/service.asmx/HelloWord, function(response) {
data = response;
}).error(function(){
alert(Sorry could not proceed);
});

return data;
}


OR :



function fun() 
{
var data=hello;
$.post('http://localhost/ws/service.asmx/HelloWord',{},function(response)
{ data = response;
}).error(function(){
alert(Sorry could not proceed);
});

return data;
}

[#72850] Wednesday, January 29, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cristinadomoniquel

Total Points: 320
Total Questions: 94
Total Answers: 94

Location: Moldova
Member since Sat, Aug 6, 2022
2 Years ago
cristinadomoniquel questions
Wed, Apr 7, 21, 00:00, 3 Years ago
Tue, Dec 1, 20, 00:00, 4 Years ago
Mon, Nov 23, 20, 00:00, 4 Years ago
Mon, Aug 17, 20, 00:00, 4 Years ago
;