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 :: shorten req.body. function 
Javascript :: .catch() in promise will aslo return a promise 
Javascript :: know if a gridview is empty from javascript 
Javascript :: check if element is displayed 
Javascript :: uplaod file in s3 from heroku for node js 
Javascript :: javascript change color of button onclick 
Javascript :: convert json results 
Javascript :: cara install parrot os di virtualbox 
Javascript :: (error) => { console.log(error); } 
Javascript :: The setTimeout() method receives the second parameter in 
Javascript :: To disable server-to-server and REST tools like Postman to access our API - Remove !origin from your if statement. 
Javascript :: imleç 
Javascript :: angular pipe to capitalize all letters 
Javascript :: nodejs createwriteStream file image broken 
Javascript :: how take a item from object javascript 
Javascript :: How to Use the Return Keyword in a Function 
Javascript :: pause media stream javascript 
Javascript :: check if a text field is empty javascript 
Javascript :: pushReplacement Method 
Javascript :: MongoDb read operation 
Javascript :: Backbone Save Example 
Javascript :: Load RequireJS Script 
Javascript :: Colored tab in react Js MUI 
Javascript :: pass prop through route 
Javascript :: Parsing the URL string using the Legacy API 
Javascript :: js create an object from another object with some keys removed 
Javascript :: v-if disable vue 
Javascript :: javascript call example 
Javascript :: jquery select vs create syntax 
Javascript :: translate javascript to english 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =