top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is JSONP and how to use it?

0 votes
288 views
What is JSONP and how to use it?
posted Jul 9, 2017 by Shyam Chakraborty

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

JSONP stands for JSON with padding. It is a method used to bypass the cross-domain policies in web browsers. In other words, JSONP is the simple way to deal with browser restrictions when sending JSON responses from different domains from the client.

Example

$.ajax({
  //JSONP API
  url: "http://remote.domain.com/data/?callback=jsonpcallback&id=123",
  //the name of the callback function
  jsonp: "jsonpcallback",
  //tell jQuery to expect JSONP
  dataType: "jsonp",
  //tell YQL what we want and that we want JSON
  data: {
    id: "123"
  },
  //work with the response
  success: function(data) {
    console.log(data); //formatted JSON data
  }
});
answer Jul 11, 2017 by Debaprasad Maity
...