Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

How to make a JSON call to an URL

function getJSONP(url, success) {

    var ud = '_' + +new Date,
        script = document.createElement('script'),
        head = document.getElementsByTagName('head')[0] 
               || document.documentElement;

    window[ud] = function(data) {
        head.removeChild(script);
        success && success(data);
    };

    script.src = url.replace('callback=?', 'callback=' + ud);
    head.appendChild(script);

}

getJSONP('http://soundcloud.com/oembed?url=http%3A//soundcloud.com/forss/flickermood&format=js&callback=?', function(data){
    console.log(data);
});  
Comment

How to make a json call to a URL

function getJSON(url, success) {
  var ud = '_' + +new Date,
      script = document.createElement('script'),
      head = document.getElementsByTagName('head')[0] || document.documentElement;

  window[ud] = function(data) {
      head.removeChild(script);
      success && success(data);
  };

  script.src = url.replace('callback=?', 'callback=' + ud);
  head.appendChild(script);
}

getJSON('http://soundcloud.com/oembed?url=http%3A//soundcloud.com/forss/flickermood&format=js&callback=?', function(data){
  console.log(data);
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: area selection on image using javascript 
Javascript :: sorting algorithms in node.js 
Javascript :: paginacion javascript 
Javascript :: JavaScript Creating Symbol 
Javascript :: create index mongodb 
Javascript :: palindrome checker 
Javascript :: dates in javascript 
Javascript :: how to check popup is open or not in javascript 
Javascript :: yarn create react app in current directory 
Javascript :: sequelize update index column 
Javascript :: json remove &#34 
Javascript :: access text inside a button from js 
Javascript :: react-with-firebase-auth 
Javascript :: componentdidmount react hooks 
Javascript :: add material angular 
Javascript :: how to create a react app 
Javascript :: fluent validation email address regex 
Javascript :: how to print hello world in javascript 
Javascript :: javascript got device ip 
Javascript :: map within a map javascript 
Javascript :: submit form jquery browser check 
Javascript :: How do I access a class without an instance? +javascript 
Javascript :: app script append two list 
Javascript :: javascript dom manipulation 
Javascript :: detect localstorage limit 
Javascript :: data-toggle="tooltip not working due to jquery-ui.min.js 
Javascript :: react native comment in render 
Javascript :: before unload 
Javascript :: navigation scroll react 
Javascript :: math module js 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =