calling a webservice through javascript
-
Hi Can someone tell me what are the pros and cons of calling a web-service through JavaScript instead of calling a web-service through c# or vb.net??? Regards
sAqIb "Our scientific power has outrun our spiritual power. We have guided missiles and misguided men." Dr. Martin Luther King Jr.
-
Hi Can someone tell me what are the pros and cons of calling a web-service through JavaScript instead of calling a web-service through c# or vb.net??? Regards
sAqIb "Our scientific power has outrun our spiritual power. We have guided missiles and misguided men." Dr. Martin Luther King Jr.
<%@ WebService Language="VB" Class="Samples.AspNet.SimpleWebService" %> Imports System.Web Imports System.Web.Services Imports System.Xml Imports System.Web.Services.Protocols Imports System.Web.Script.Services Namespace Samples.AspNet _ _ _ Public Class SimpleWebService Inherits System.Web.Services.WebService _ Public Function EchoInput(ByVal input As String) As String Dim inputString As String = Server.HtmlEncode(input) If Not String.IsNullOrEmpty(inputString) Then Return String.Format("You entered {0}. The " + _ "current time is {1}.", inputString, DateTime.Now) Else Return "The input string was null or empty." End If End Function 'EchoInput End Class 'SimpleWebService End Namespace This is asmx File and this is aspx file <%@ Page Language="VB" %> body { font: 11pt Trebuchet MS; font-color: #000000; padding-top: 72px; text-align: center } .text { font: 8pt Trebuchet MS } Simple Web Service // This function calls the Web Service method. function EchoUserInput() { var echoElem = document.getElementById("EnteredValue"); Samples.AspNet.SimpleWebService.EchoInput(echoElem.value, OnSucceeded); } </x-turndown>
-
<%@ WebService Language="VB" Class="Samples.AspNet.SimpleWebService" %> Imports System.Web Imports System.Web.Services Imports System.Xml Imports System.Web.Services.Protocols Imports System.Web.Script.Services Namespace Samples.AspNet _ _ _ Public Class SimpleWebService Inherits System.Web.Services.WebService _ Public Function EchoInput(ByVal input As String) As String Dim inputString As String = Server.HtmlEncode(input) If Not String.IsNullOrEmpty(inputString) Then Return String.Format("You entered {0}. The " + _ "current time is {1}.", inputString, DateTime.Now) Else Return "The input string was null or empty." End If End Function 'EchoInput End Class 'SimpleWebService End Namespace This is asmx File and this is aspx file <%@ Page Language="VB" %> body { font: 11pt Trebuchet MS; font-color: #000000; padding-top: 72px; text-align: center } .text { font: 8pt Trebuchet MS } Simple Web Service // This function calls the Web Service method. function EchoUserInput() { var echoElem = document.getElementById("EnteredValue"); Samples.AspNet.SimpleWebService.EchoInput(echoElem.value, OnSucceeded); } </x-turndown>
Thanks to provide the code. But my question was to tell me the advantages as well as disadvantages of calling a web-service through JavaScript. If you know then please write them here. Regards
sAqIb "Our scientific power has outrun our spiritual power. We have guided missiles and misguided men." Dr. Martin Luther King Jr.
-
Thanks to provide the code. But my question was to tell me the advantages as well as disadvantages of calling a web-service through JavaScript. If you know then please write them here. Regards
sAqIb "Our scientific power has outrun our spiritual power. We have guided missiles and misguided men." Dr. Martin Luther King Jr.
Hmm, no postback?
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
-
Hmm, no postback?
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
-
You cant achieve this using javascript, you have to use AJAX for this purpose
Best Regards, Haissam Abdul Malak My Blog
AJAX stands for Asynchronous Javascript And XML, duh.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
-
AJAX stands for Asynchronous Javascript And XML, duh.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
-
Hi Can someone tell me what are the pros and cons of calling a web-service through JavaScript instead of calling a web-service through c# or vb.net??? Regards
sAqIb "Our scientific power has outrun our spiritual power. We have guided missiles and misguided men." Dr. Martin Luther King Jr.
http://www.codeproject.com/soap/marcelo888RemoteScript01.asp[^]
Vasudevan Deepak Kumar Personal Homepage Tech Gossips