2016-04-10 19 views
0

JSON'dan veri almak ve JQuery ile kullanmak için bir çalışma kodum var. JQuery olmadan yapabilir miyim? Nasıl yapabilirim?JSON verilerini JQuery olmadan TVML prohectine alın

function performRequest(type, route, data) { 
     return $.ajax({ 
      type: type, 
      dataType: 'json', 
      url: '...' + route, 
      data: data 
     }); 
    } 

    function getChannels() { 
     log(' > get channels'); 
     return performRequest('GET', 'channel/list', {id: browserId}).then(function (response) { 
      response.data.forEach(function (channel) { 
       channels[channel.id] = channel; 
      }); 
     }); 
    } 

cevap

1

XMLHttpRequest Kullanma? Bunun gibi - bir TV2/3 ...

var req = new XMLHttpRequest(); 
req.onreadystatechange = function() 
{ 
    if (req.readyState==4) // 4: request is complete 
    { 
     data = JSON.parse(req.responseText); 
    } 
}; 
req.open('GET', url, true); // true: asynchronous 
req.send(); 
üzerinde çalışır.
İlgili konular