Note that there are some explanatory texts on larger screens.

plurals
  1. POPure JSONP request with Ajax using jQuery
    primarykey
    data
    text
    <p>Ok. I have searched everywhere and didnt find any understandable answer. Please note its the first time i'm implementing this kind of request. ("Happens to everyone i think"):P The problem: I have a json file say for example <a href="https://www.example.com/something.json" rel="nofollow">https://www.example.com/something.json</a> and i want to request it through JSONP using Ajax. I've read that in order to make a JSONP request you have to wrap data to a callback function. So i edited my php file that generates the json file and added the $_GET('callback') function to wrap data. So if i type to a browser <a href="https://www.example.com/something.json/?callback=jsonpCallBack" rel="nofollow">https://www.example.com/something.json/?callback=jsonpCallBack</a> i can see my data wrapping jsonpCallBack([{.......}]);</p> <p>In jQuery now i am trying to access this information and append the data to html every 20 seconds. So i have </p> <pre><code> 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='&lt;ul&gt;'; var item = []; for(var i =0; i &lt; data.length-1 ;i++) { var item = data[i]; .......... $('.div').html(outputhtml) ; } }); setInterval(function() { main; },20000); main; </code></pre> <p>But instead i can't see my data updating. Did i miss something? Do i still have to use $.getJSON() function to get the data? and if yes where is going to be added in the code?</p> <p>Lots of confusion...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload