0

I'm trying to get any data from public webservice http://www.cbr.ru/DailyInfoWebServ/DailyInfo.asmx?WSDL but something goes wrong with it. Every time I get "0 error" failure alert message. Can anybody help with it?

<!DOCTYPE html>
<html>
<head>
  <script src="Scripts/jquery-1.8.3.min.js"></script>
</head>
<body>
<input type="button" id="hello" value="Get data."/>
<script>
    $("#hello").click(function () {
                $.support.cors = true;
                $.ajax({
                type: "POST", 
                url: "http://www.cbr.ru/DailyInfoWebServ/DailyInfo.asmx/EnumValutes",
                data: "{Seld : False}",
                datatype: "xml",
                success: function (msg)
                {
                   Successfullcalling(msg);
                },
                error: Failurecalling
            });
    });

    function Successfullcalling(res)
    {
        alert("Done!");
    }
    function Failurecalling(res)
     {
       alert(res.status + ' ' + res.statusText);
     } 
</script>

</body>
</html>
user485553
  • 161
  • 2
  • 14
  • possibly duplicate question http://stackoverflow.com/questions/5551423/calling-wsdl-service-via-jquery – SubRed Nov 26 '12 at 11:17

2 Answers2

2

I think the problem is a cross domain request. On which domain work you'r script?

Boris Pavlovic
  • 1,279
  • 8
  • 17
  • Domain is different from mine, but I think that $.support.cors = true; should help with it. – user485553 Nov 26 '12 at 11:45
  • I think you should also set crossDomain to true (it is by default false) – Boris Pavlovic Nov 26 '12 at 11:52
  • I'm not sure but maybe you should send as data not "{Seld : False}", but {"Seld" : false} or {"Seld" : "False"}. – Boris Pavlovic Nov 26 '12 at 12:29
  • I think it is a different problem with it, because when I try invoke a method without params and I get the same result "0 and error". – user485553 Nov 26 '12 at 13:02
  • I will try to find a different solution for this problem. I also found this "note that many browsers do not allow cross-domain calls for security reasons" may be it is a reason of the problem. – user485553 Nov 26 '12 at 13:05
  • I tried to make such query on site. There is no problem with crossDomain. I got every time 302 code. So somethings is not ok with url. P.S. You should send {"Seld" : false} or {"Seld" : "False"} (I don't know exactly) But I'm sure that not "{Seld : False}". Also you should set up crossDomain to true. – Boris Pavlovic Nov 26 '12 at 13:22
0

as Boris has said in his reply this is the problem of cross domain request

have a look at this

jQuery Ajax - Status Code 0?

Community
  • 1
  • 1
rahul
  • 7,573
  • 7
  • 39
  • 53