JSON Web Service, Parameter Passing

J

Jennifer Mathews

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top