locked
Check internet speed Javascript

    Question

  • I am fetching some information from internet in my app.

    When internet is slow the app get crashed, when internet is fast it works fine.

    How can i fix this problem?

    Monday, April 1, 2013 7:07 AM

Answers

  • Try enabling JavaScript debugging option of Visual Studio to check what the exception is all about. In Visual Studio, choose Debug -> Exceptions -> JavaScript Runtime Exceptions.


    @prashantphadke || Windows Store Developer Solutions #WSDevSol || Want more solutions? See our blog! http://aka.ms/t4vuvz

    • Marked as answer by Song Tian Friday, April 5, 2013 9:13 AM
    Wednesday, April 3, 2013 10:56 PM
    Moderator

All replies

  • How are you fetching information from internet? What class/API are you using? A code snippet would help.

    @prashantphadke || Windows Store Developer Solutions #WSDevSol || Want more solutions? See our blog! http://aka.ms/t4vuvz

    Monday, April 1, 2013 4:50 PM
    Moderator
  • badge = element.querySelector("#weather-text");

    var jsonResult;
    var my_urls = 'http://free.worldweatheronline.com/feed/weather.ashx?q=52.40637,16.92517&format=json&num_of_days=5&key=YourAPIKey';

    //*********weather fetching code here

                WinJS.xhr(
                {
                    url: my_urls,
                    data: {},
                    responseType: 'json',
                    type: 'GET',
                }
                ).then(function complete(response) {
                    jsonResult = response.responseText;
                    obj = JSON.parse(jsonResult);

                            badge.innerHTML = "Temprature: " + obj.data.current_condition[0].temp_C + "°C";

                            badge.innerHTML = "Humidity: " + obj.data.current_condition[0].humidity + "%";
                    }
                //Error and Progress functions
                ),
                        function error(request) {
                            // handle error conditions.
                        },
                function progress(request) {
                    // report on progress of download.
                };

    Tuesday, April 2, 2013 4:42 AM
  • Try enabling JavaScript debugging option of Visual Studio to check what the exception is all about. In Visual Studio, choose Debug -> Exceptions -> JavaScript Runtime Exceptions.


    @prashantphadke || Windows Store Developer Solutions #WSDevSol || Want more solutions? See our blog! http://aka.ms/t4vuvz

    • Marked as answer by Song Tian Friday, April 5, 2013 9:13 AM
    Wednesday, April 3, 2013 10:56 PM
    Moderator