This is a migrated thread and some comments may be shown as answers.

Web Service Help

3 Answers 183 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Troy Clemons
Top achievements
Rank 1
Troy Clemons asked on 23 Mar 2012, 03:49 PM
I am new to the HTML5 and Kendo UI stuff. is there any Hello World Example for accessing a web service
and returning the String to a div.


Thank you

3 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 23 Mar 2012, 04:35 PM
Hi,

You can use the jQuery load methods to do this:

$('#result').load('WebService.asmx/Method');

You can find more info in this blog post.

Regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Troy Clemons
Top achievements
Rank 1
answered on 23 Mar 2012, 06:09 PM
HTML Code
<html>
<head>
    <title>DSR v2.0 Login</title>
    <script src="js/jquery.min.js" type="text/javascript"></script>
    <script src="js/kendo.web.min.js" type="text/javascript"></script>
    <script src="content/shared/js/console.js" type="text/javascript"></script>
    <link href="styles/kendo.common.min.css" rel="stylesheet" />
    <link href="styles/kendo.default.min.css" rel="stylesheet" />
</head>
<body>
     
    <script type="text/javascript">
        $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: "DSR.asmx/HelloWorld",
            success: function (msg) {
                alert(msg.d);
            },
            error: function (msg) {
                alert(msg.d);
            }
        });
    </script>
</body>
</html>

Web Service
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
 
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class DSR
    Inherits System.Web.Services.WebService
 
    <WebMethod()> _
    Public Function HelloWorld() As String
       Return "Hello World"
    End Function
 
End Class


alert box comes back with undefined and Not Hello World.

What am i missing..........

Thank you for the help
0
Troy Clemons
Top achievements
Rank 1
answered on 26 Mar 2012, 04:07 PM
i got it..
need to add
<WebMethod(EnableSession:=True)> _
    <ScriptMethod(ResponseFormat:=ResponseFormat.Json)>

 to your web service

and import 
Imports System.Web.Script.Services

and make sure that you allow a service to be called from script.
From this:
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
'<System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
 
to This
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
<System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _

Tags
Data Source
Asked by
Troy Clemons
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Troy Clemons
Top achievements
Rank 1
Share this question
or