views:

150

answers:

4

How we can call webservice from html page using javascript

+5  A: 

You use Ajax. Specifically, the XMLHttpRequest object in JS.

Oded
And you think his is the difficult case?
Oded
+4  A: 
  1. Because of same origin restrictions, you might need to use JSONP through script injection.

  2. Of course if you are talking a Web Service on the same origin, just use AJAX.

  3. Through an web browser extension

jldupont
IMO this is the most appropriate answer for *web services*. Here's more info on utilizing JSONP with jQuery: http://docs.jquery.com/Ajax/jQuery.getJSON and here's more info on JSONP itself: http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/
cballou
A: 

Yes you can. Did you try googling ?

ram
Why not go whole-hog and just LMGTFY him? This is a place for asking questions.
T.J. Crowder
Yes, this is definitely a place for asking questions. I believe they should also put some effort in trying to find an answer than just posting in SO and expecting someone else to solve their problem
ram
I agree with your comments Ram ..
infant programmer
I agree with you .. Not because anyone gets troubled with the silly questions .. but its a good thing to "TRY" before we give-up and ask some one for help .. so +1 for you ..
infant programmer
A: 

using jQuery:

$.ajax({ 
    type: "POST", 
    contentType: "application/json; charset=utf-8", 
    url: "WebService.asmx/WebMethodName", 
    data: "{}", 
    dataType: "json"
});
Mark