locked
RETRIEVE DATA FROM CLOUD

    Question

  • How do I retrieve data from my cloud url?

    I need a javascript connection.

    im not sure how to do it.


    1002614D

    Friday, August 24, 2012 6:55 AM

All replies

  • Hi Megenta,

    It depends on what kind of data it is.  How do you normally access it?  Can you provide some more details?

    -Jeff


    Jeff Sanders (MSFT)

    Friday, August 24, 2012 7:28 PM
    Moderator
  • currently, I have done this. but I want to change the hardcoded array to the one I retrieve from my cloud url. how do I do that?

    var latitude4;

     

    var longitude4;

     


    var results1;

     


    var count1 = 0;

     


    var results = newArray;

     



    varlat3 = newArray(3);

     

    lat3[1] = "1.357272";

    lat3[2] = "1.353301";

    lat3[3] = "1.349083";



    var lon3 = newArray(3);

     

    lon3[1] = "103.946618";

    lon3[2] = "103.954589";

    lon3[3] = "103.935484";





    var lat1 = "";

     



    var lon1 = "";

     



    var dist = "";

     



    function distance() {

     

     

     

        lat1 = document.getElementById('latitude').innerHTML;

        lon1 = document.getElementById('longitude').innerHTML;

     

       

    vard;

       

    varR;

       

    varcount = 0;

     

       

    for(x in(lat3 && lon3)) {

     

            R = 100;

    // km


            d = Math.acos(Math.sin(lat1) * Math.sin(lat3[count]) + Math.cos(lat1) * Math.cos(lat3[count]) * Math.cos(lon3[count] - lon1)) * R;

            count += 1;

            results.push(d);

           

        }

       

       

    //RESEARCH


       

    //http://stackoverflow.com/questions/8848779/why-math-min-math-max


       

    varx = Math.min();

       

    varcount = 0;

       

       

    for(vari = 0; i <  results.length; i++) {

           

    if(results[i] < x) { // will succeed on first iteration


               

    // because `x` is initialised to highest possible value


                x=results[i];

                results1 = x;

                count = i;

            }

    //End of if statement


        }

            latitude4 = lat3[count];

              longitude4 = lon3[count];

              ccid = count;

             

       

         }


    1002614D

    Monday, August 27, 2012 3:50 AM
  • You could use WinJS.xhr().

    Here is a quickstart sample that explains how you can use it: http://msdn.microsoft.com/en-us/library/windows/apps/hh868282.aspx

    Monday, August 27, 2012 9:48 AM
  • Hi Magenta,

    What is the cloud URL you are using?  Is it something you wrote yourself or a 3rd party URL?

    -Jeff


    Jeff Sanders (MSFT)

    Monday, August 27, 2012 3:54 PM
    Moderator
  • it is something I wrote myself

    1002614D

    Tuesday, August 28, 2012 1:23 AM
  • I have created a function.

    function retrive() {

     

       

    varxhrDiv = document.getElementById("cclatitude");

        WinJS.xhr({ url: gbaseurl })

            .done(

    functioncomplete(result) {

               

    // Report download.


                xhrDiv.innerText = "Downloaded the page";

                xhrDiv.style.backgroundColor = "#00FF00";

            },

               

    functionerror(error) {

                    xhrDiv.innerHTML = "Got error: "+ error.statusText;

                    xhrDiv.style.backgroundColor = "#FF0000";

                },

               

    functionprogress(result) {

                    xhrDiv.innerText = "Ready state is "+ result.readyState;

                    xhrDiv.style.backgroundColor = "#0000FF";

                });

    }

     but unfortunately the xhrDiv value when I put a breakpoint is (....). im not sure what is happening. but I want to put the value in the cclatitude in my array.


    1002614D

    Tuesday, August 28, 2012 1:44 AM
  • There is not enough information to help you.

    Where is the breakpoint?  Is the problem that xhr is failing?  Does xhr succeed?  Are you saying when you set the innerText to a static string it is not displaying?


    Jeff Sanders (MSFT)

    Tuesday, August 28, 2012 12:25 PM
    Moderator