Pure JSONP request with Ajax using jQuery -


ok. have searched everywhere , didnt find understandable answer. please note first time i'm implementing kind of request. ("happens think"):p problem: have json file example https://www.example.com/something.json , want request through jsonp using ajax. i've read in order make jsonp request have wrap data callback function. edited php file generates json file , added $_get('callback') function wrap data. if type browser https://www.example.com/something.json/?callback=jsonpcallback can see data wrapping jsonpcallback([{.......}]);

in jquery trying access information , append data html every 20 seconds. have

      var url='https://www.example.com/something.json/?callback=jsonpcallback';        var main= $.ajax({                 type:'get',                 url : url,                  datatype:'jsonp',                 jsonpcallback:'jsonpcallback',                 success: function(data)                 {                     .......                      var outputhtml='<ul>';                      var item = [];                       for(var =0; < data.length-1 ;i++)                       {                          var item = data[i];                         ..........                      $('.div').html(outputhtml) ;                 }              });  setinterval(function() {     main; },20000);      main; 

but instead can't see data updating. did miss something? still have use $.getjson() function data? , if yes going added in code?

lots of confusion...

try this:

var main = function() {     var url = 'https://www.example.com/something.json/';     $.ajax({         url: url,         jsonp: 'callback',         datatype: 'jsonp',         success: function (result) {             ...         }     }); };  window.setinterval(main, 20000); main(); 

which work if https://www.example.com/something.json/?callback=foobar returns following result (which mentioned being case in question, right?):

foobar({...}) 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -