• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 425
  • Last Modified:

JQuery / asp .net web service

Hi- I am trying to implement a web service with Jquery

Below is my code:

All i want it to do is post the data and return the "Hello World"

I keep getting a 500 Internal Server Error...

Just looking to do a simple Post

Any help would be appreciated (p.s. I'm using 2.0 framework - if that matters)
function removeImage(id) {
                $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: "ProductPhotoDelete.asmx/HelloWorld",
                data: { a: 1, b: "test" },  
                dataType: "json",
                success: AjaxSucceeded,
                error: AjaxFailed
            }); 
    }

 function AjaxSucceeded(result) {
        alert(result.d);
    }

    function AjaxFailed(result) {
        alert(result.status + ' ' + result.statusText);
    }  

'----------------------------------------------------------------------------------

Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols

' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
<System.Web.Script.Services.ScriptService()> _
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class ProductPhotoDelete
    Inherits System.Web.Services.WebService

    <WebMethod()> _
    Public Function HelloWorld(ByVal a As Integer, ByVal b As String) As String
        Return "Hello World"
    End Function

    <WebMethod()> _
     Public Function HelloToYou(ByVal name As String) As String
        Return "Hello " + name
    End Function

Open in new window

0
doctor069
Asked:
doctor069
1 Solution
 
doctor069Author Commented:
Got it -

Data has to be sent as a string

var myDataSerialized = JSON.stringify(id);
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now