Error trying to return data from web service using json

koda

New Member
I am receiving "Internal Server Error" trying to call a web service method from json.Here is the WebService code:\[code\]Imports System.Web.ServicesImports System.Web.Services.ProtocolsImports System.ComponentModel<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 WebService1Inherits System.Web.Services.WebService <WebMethod()> _ Public Function HelloWorld() As String Return "Hello World" End FunctionEnd Class\[/code\]The calling page's markup and script is as follows:\[code\]<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" %><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>WebForm1</title> <script src="http://stackoverflow.com//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script > $(document).ready(function () { // Add the page method call as an onclick handler for the div. $("#Result").click(function () { $.ajax({ type: "POST", url: "WebService1.asmx/HelloWorld", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", error: function(xhr, status, error) { $("#Result").html("xhr: " + xhr.text + "</br>Status: " + status + "</br>Error: " + error); }, success: function (data) { $("#Result").html(data.d); } }); }); }); </script></head><body> <div id="Result">Click here ...</div><br/> <input id="KenID" /></body></html>\[/code\]I am not sure what to check to make this simple application work.Will appreciate some hints.Jacek
 
Back
Top