views:

30

answers:

4

I've spent a week trying to use http://monitoring-gps.com.ua/aspservices/asptest.asmx methods on client side. How to do that?

A: 

There are a few options here:

  1. Make a web reference using visual studio and then you can access it via javascript after you put a script service reference in the .aspx page http://msdn.microsoft.com/en-us/magazine/cc163499.aspx

  2. Use JQuery to make a ajax call. http://api.jquery.com/jQuery.ajax/

Avitus
+1  A: 

You can use jquery to do this -- look at http://encosia.com/2008/03/27/using-jquery-to-consume-aspnet-json-web-services/

TheGeekYouNeed
+1  A: 

Use Ajax + Jquery: http://api.jquery.com/jQuery.ajax/

$.ajax( {
                                    type: "POST",
                                    contentType: "application/json; charset=utf-8",
                                    dataType: "json",
                                    url: "http://monitoring-gps.com.ua/aspservices/asptest.asmx/METHODNAME",                                                            
                                    data: "{'paramName':'" + ParamValue + "'}",
                                    success: function(data) { alert("That works;") }  
                                });
Rbacarin
$.ajax( { type: "POST", contentType: "application/json; charset=utf-8", dataType: "json", url: "http://monitoring-gps.com.ua/aspservices/asptest.asmx/DeviceList", data: "{}", success: function(data) { alert("That works;") } });Maybe I did something wrong?
Artem
A: 

As far as I know, you can't call a cross domain web service via java script. If you try to call a web service within your web application in javascript, it will work. You need to find some workaround . This link should be helpful http://www.simple-talk.com/dotnet/asp.net/calling-cross-domain-web-services-in-ajax

Ashok