JSON Web Service, Parameter Passing

Discussion in 'ASP .Net Web Services' started by Jennifer Mathews, Mar 14, 2009.

  1. The web service succesfully gets called if data: {} (no parameters)
    But if I try to pass a parameter, an error occurs.
    The Code Behind doesn't seem to like the parameter passing.

    What am I doing wrong when passing the parameter?
    I have tried:
    //"{'fname':'dave'}" << doesnt work
    //"{fname:dave}" << doesnt work
    and actually a few others that I am too embarrassed to print.


    $.ajax({
    type: "POST",
    url: "wsLkup2_Load.asmx/Lkup2_Load",
    data: {fname:dave}, << Error with ANY parameter. Works if just {} (no
    parameters)
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(result) {
    alert(result.d);
    },
    error: function(req, status, error) {
    alert('asdfasdf ERROR');
    }
    });

    CODE BEHIND
    ===========

    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)> _
    Public Class wsLkup2_Load
    Inherits System.Web.Services.WebService

    <WebMethod()> _
    Public Function Lkup2_Load(ByVal p_s_UsrID As String) As String
    ' if the parameter is removed, the web service is successfully called.
    Return "Hello World"
    End Function

    End Class
     
    Jennifer Mathews, Mar 14, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Florian Frank
    Replies:
    0
    Views:
    243
    Florian Frank
    Jun 30, 2009
  2. sajuptpm
    Replies:
    2
    Views:
    344
    sajuptpm
    Dec 28, 2012
  3. Acácio Centeno
    Replies:
    1
    Views:
    258
    dieter
    Feb 15, 2013
  4. Bryan Britten
    Replies:
    9
    Views:
    264
    Bryan Britten
    May 28, 2013
  5. David Karr
    Replies:
    1
    Views:
    169
    David Karr
    Jun 17, 2013
Loading...

Share This Page