Saturday, March 24, 2012

Invoking a Web Service through JavaScript

Hi,

I keep getting the 'WebService is undefined' error when I try to

access my Web Service through JavaScript. I have made all necessary changes -added handlers to

the web.config file, included the DLL in the bin directory, included referernce through the

<ScriptManager> tag...

<atlas:ScriptManager ID="ScriptManager" runat="server" enablepartialrendering="true">
<Services>
<atlas:ServiceReference Path="/TestAJAXApp/MyWebService.asmx" />
</Services>
</atlas:ScriptManager>

<script type ="text/javascript">
function MyCustomFunction(MyRecordID, event)
{
var result = MyWebService.GetRecordDescription(MyRecordID, GetCallBack);
}
function GetCallBack(result)
{
Popup('Description' , result.value, false);
}
</script>

What could I be missing? Any suggestions appreciated.

Thanks!

The first thing to double check, is whether the request for the webservice proxy succeeded or not, use fiddler or whatever your favorite http traffic monitoring tool is, and verify that there indeed is a request to an url like /TestAJAXApp/MyWebService.asmx/js and that the response of that is the client javascript proxy for your webservice. My guess is that is failing in some way, and hopefully that will lead you to the problem...

Hope that helps,
-Hao

No comments:

Post a Comment