0
votes

the methods below used to work but now I get this error: Error: Sys.Net.WebServiceFailedException: The server method ' failed with the following error: System.Net.WebException-- Unable to connect to the remote server how can I fix it?

function CallMe() {

    // call server side method
    PageMethods.GetData(function (result) {
        DcSet("lblUsdRub", result.UsdRub);
        DcSet("lblEurRub", result.EurRub);
        DcSet("lblMicex", result.Micex);
        DcSet("lblUrals", result.Urals);
        DcSet("lblUsdEur", result.UsdEur);
        DcSet("lblUsdTur", result.UsdTur);
        DcSet("lblNasdaq", result.Nasdaq);
        DcSet("lblImkb100", result.Imkb100);
    });
 }
 function DcSet(labelName, value) {

         document.getElementById(labelName).innerText = value.toFixed(3);

 }



(function () {
 var status = true;
 var fetchService = function () {
     if (status) {
         CallMe();
         status = false;

     }
     setTimeout(fetchService, 300000); //Every Five Minutes, Update Data 300000
     status = true;
 }
 addLoadEvent(fetchService);
// window.onload = fetchService;
 } ());

function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function () {
            if (oldonload) {
                oldonload();
            }
            func();
        }
    }
}

the aspx.cs file using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.Services; using System.Web.Script.Services;

public partial class Index : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    [WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public static OnlineData GetData()
    {
        return ExternalManager.GetOnlineData();
    }
}

the aspx file

     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
     <meta name="description" content="">
     <meta name="keywords" content=""> 

    <link rel="stylesheet" type="text/css" href="/c/main.css">
    <script src="/c/main.js" type="text/javascript"></script>

    <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">

</head>
<body>
<script src="/c/Currency.js" type="text/javascript" ></script>
    <form id="form1" runat="server">
       <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true"  >

     </asp:ScriptManager>
    <div id="Content">
        <div class="nobg">

            <div id="Top">
                <div class="left">
                    <a href="index.aspx"><img src="/i/xxxx.gif" alt="xxxx" /></a>
                </div>

                <div class="right">
1

1 Answers

1
votes

Given that you're getting a .NET exception, it sounds like the AJAX call is managing to get to your WebMethod without any problems - it sounds like ExternalManager.GetOnlineData(); is failing.

I suggest you try calling that in a simple console application which you can debug easily.