Showing posts with label seperate. Show all posts
Showing posts with label seperate. Show all posts

Wednesday, March 28, 2012

Calling a WebMethod from JavaScript (In another directory) doesnt work

Hello everybody,

I have a Web Part and in that web part (ascx) and in a seperate directory (Javascript/Authentication/login.js) I have a javascript.

I have a web method from the other side that check and see if a user is available or not. I know 100% my webmethod is working because when I run it I can test the webmethod in browser from Visual Studio.

The problem is that when even I try to access that webmethod (webservice) the error : WebService is not defined pops up.

I want to know why this is happening ? Is it because I have my javascript in a seperate file other than my web service file (asmx) ?


I appreciate any help.

Thanks.

Please totally forgive me, I had a syntax error, I fixed it now, working fine.

I typed the name of my web service wrong.

Sorry Again.

Saturday, March 24, 2012

Call an external web service from AJAX

HI,

I have tried ServiceReference element in ajax but it allows me to use a webservice if its part of the same project only.

What if i ahve a seperate webservice project and i want to refere webmethod from that service?

How i can call a webmethod that is in service outside of my project?

THanks,

You write a wrapper WebService to call the external one. While there is a constraint on JavaScript calling external WebServices, there's nothing to stop your WebService calling external WebServices.

Write yourself a WebService which can be called from your JavaScript then have that WebService call the external one, passing the results back to your javascript

You'll need to use the WebRequest and WebResponse objects in your WebService, or maybe you can set up a proxy in the same way you'd reference a WebService in the normal way


Hi,

the following article might help:

http://dotnetslackers.com/columns/ajax/MashitUpwithASPNETAJAX.aspx