{"id":1096,"date":"2014-11-11T15:00:27","date_gmt":"2014-11-11T13:00:27","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=1096"},"modified":"2014-11-07T01:09:04","modified_gmt":"2014-11-06T23:09:04","slug":"getting-started-with-json-p","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/javascript\/getting-started-with-json-p\/","title":{"rendered":"Getting started with JSON-P"},"content":{"rendered":"<p>I have during my college days used XMLHttpRequest object and its equivalent in Microsoft world to make Ajax calls and those Ajax calls were to the URL within the same domain. But with the advent of Webservices and whole lot of mashups being developed, Ajax calls are not restricted to same domain but the cut acorss different domains. When this cutting across domain boundaries happens making Ajax calls using XMLHttpRequest fails due to security enforcements implemened by the browsers. That\u2019s when the idea of JSON-P i.e JSON with Padding came up.<\/p>\n<p>In this post I will quote from different sources about JSONP and then go ahead and implement example which invokes Stackoverflow API to retrieve the unanswered questions tagged \u2018jsonp\u2019<\/p>\n<ol>\n<li><a href=\"#jsonp\">What is JSONP?<\/a><\/li>\n<li><a href=\"#ex1\">Simple example for JSONP<\/a><\/li>\n<li><a href=\"#ex2\">Accessing Stackoverflow API using JSONP<\/a><\/li>\n<\/ol>\n<h2><a name=\"jsonp\"><\/a>What is JSONP?<\/h2>\n<p>I am not going to restate its definition, instead quote its definition from different sources as given below:<\/p>\n<h3><strong>From Head First HTML5:<\/strong><\/h3>\n<blockquote><p>\u00a0JSONP is a way to retrieve JSON objects by using the <code>script<\/code> tag. It\u2019s also a way of retrieving data (again, in the form of JSON objects) that avoids the same-origin security issues we saw with XMLHttpRequest. JSONP is JSON data wrapped in JavaScript; typically, a function call.<\/p><\/blockquote>\n<h3><strong>From http:\/\/json-p.org\/<\/strong><\/h3>\n<blockquote><p>One such mechanism which can request content cross-domain is the <code>script<\/code> tag. In December 2005, Bob Ippolito formally proposed JSONP (later dubbed JSON-P, or JSON-with-padding) as a way to leverage this property of <code>script<\/code> tags to be able to request data in the JSON format across domains. JSON-P works by making a <code>script<\/code> element (either in HTML markup or inserted into the DOM via JavaScript), which requests to a remote data service location. The response (the loaded \u201cJavaScript\u201d content) is the name of a function pre-defined on the requesting web page, with the parameter being passed to it being the JSON data being requested. When the script executes, the function is called and passed the JSON data, allowing the requesting page to receive and process the data.<\/p><\/blockquote>\n<h3><strong>From Wikipedia: http:\/\/en.wikipedia.org\/wiki\/JSONP<\/strong><\/h3>\n<blockquote><p>JSONP or \u201cJSON with padding\u201d is a communication technique used in JavaScript programs which run in Web browsers. It provides a method to request data from a server in a different domain, something prohibited by typical web browsers because of the same origin policy.<\/p><\/blockquote>\n<p><em>Summarising, JSONP is a communication technique to retrieve data from some URL and then leveraging the <code>script<\/code> tag to establish the communication and JavaScript to update the HTML.<br \/>\n<\/em><br \/>\nThere have been a lot of concerns about how secure using JSONP is, but I dont want to get into those discussions as that is not the main motive of this post.<\/p>\n<p>Now going forward, let me show JSONP in action using a simple example.<\/p>\n<h2><a name=\"ex1\"><\/a>Simple example for JSONP<\/h2>\n<p>For the simple example I will make use of some resources from chapter on JSONP in Head First HTML5 book. I am going to make a JSONP call to a Javascript resource which in turns invokes the callback function declared in my Javascript source.<\/p>\n<p>Lets look at the HTML source:<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">&lt;html&gt;\r\n  &lt;head&gt;\r\n    &lt;title&gt;&lt;\/title&gt;\r\n    &lt;meta charset='UTF-8'&gt;\r\n    &lt;script src='simple.js'&gt;&lt;\/script&gt;\r\n  &lt;\/head&gt;\r\n  &lt;body&gt;\r\n    &lt;h1&gt;JSONP Simple Demo&lt;\/h1&gt;\r\n    &lt;!-- we will update the data here --&gt;\r\n    &lt;div id='jsonp'&gt;&lt;\/div&gt;\r\n  &lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>The interesting thing happens in the JavaScript code.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\/\/simple.js\r\nwindow.onload = function(){\r\n  \/\/Get the head element.\r\n  var head = document.getElementsByTagName('head')&#x5B;0];\r\n\r\n  \/\/url for the javascript resource for JSONP call.\r\n  var url = 'http:\/\/wickedlysmart.com\/hfhtml5\/chapter6\/dog3.js';\r\n\r\n  \/\/Appending the script tag to the head element.\r\n  \/\/This triggers a JSONP call to get the data.\r\n  var scriptTag = document.createElement('script');\r\n  scriptTag.setAttribute('src',url);\r\n  head.appendChild(scriptTag);\r\n}\r\n\r\n\/\/Method invoked by JSONP\r\nfunction animalSays(animal){\r\n  var div = document.getElementById('jsonp');\r\n  div.innerHTML = animal.type +' says '+ animal.sound;\r\n}<\/pre>\n<p>The \u201chttp:\/\/wickedlysmart.com\/hfhtml5\/chapter6\/dog3.js\u201d contains:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">var animal = { 'type': 'dog', 'sound': 'woof' };\r\nanimalSays(animal);<\/pre>\n<p>The above javascript code:<br \/>\n1. creates a JSON object<br \/>\n2. invokes the callback by pasing the JSON object.<\/p>\n<p>Now the question is, where is the <code>animalSays<\/code> method declared? If you have carefully looked at simple.js you can see that the method <code>animalSays<\/code> has been declared. When the javascript in above URL is requested using JSONP technique by dynamically adding the <code>script<\/code>, the javascript is executed in the browser which contains the definition of the <code>animalSays<\/code> method.<\/p>\n<p>The <code>animalSays<\/code> method retrieves the JSON object and then populates the HTML with the data in the JSON object.<\/p>\n<p>Lets look at a more better example.<\/p>\n<h2><a name=\"ex2\"><\/a>Accessing Stackoverflow API using JSONP<\/h2>\n<p>Details of the Stackoverflow API for unanswered questions can be found <a href=\"https:\/\/api.stackexchange.com\/docs\/unanswered-questions\" target=\"_blank\">here<\/a>. The URL for accessing unanswered questions tagged \u2018jsonp\u2019 is: https:\/\/api.stackexchange.com\/2.1\/questions\/unanswered?order=desc&amp;sort=activity&amp;tagged=jsonp&amp;site=stackoverflow<\/p>\n<p>The above URL returns some JSON data, but how does it help in making use of JSONP? One can append another parameter to the above URL called \u201ccallback\u201d which will take the name of the Javascript method which will be invoked once the URL is loaded by the <code>script<\/code> tag.<\/p>\n<p>Lets take a look at the HTML code:<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\/\/sflow.html\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n  &lt;head&gt;\r\n    &lt;title&gt;&lt;\/title&gt;\r\n    &lt;meta http-equiv='Content-Type' content='text\/html; charset=UTF-8'&gt;\r\n    &lt;script src='sflow.js'&gt;&lt;\/script&gt;\r\n  &lt;\/head&gt;\r\n  &lt;body&gt;\r\n    &lt;div&gt;Unanswered questions tagged 'jsonp'&lt;\/div&gt;\r\n    &lt;!-- placeholder for updating the questions --&gt;\r\n    &lt;div id='questions'&gt;\r\n    &lt;\/div&gt;\r\n  &lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>The Javascript code has 2 parts:<\/p>\n<ul>\n<ul>\n<li>Part-1: Loading the URL which contains the data and the function invocation.<\/li>\n<\/ul>\n<\/ul>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">window.onload = function() {\r\n  var head = document.getElementsByTagName('head')&#x5B;0];\r\n  var script = document.createElement('script');\r\n\r\n  var url = 'https:\/\/api.stackexchange.com\/2.1\/questions\/unanswered?' +\r\n          'order=desc' +\r\n          '&amp;sort=activity' +\r\n          '&amp;tagged=jsonp' +\r\n          '&amp;site=stackoverflow' +\r\n          '&amp;callback=listUnansweredQuestions';\r\n  \/\/The URL is loaded by including it in the script tag and adding to the DOM.\r\n  script.setAttribute('src', url);\r\n  head.appendChild(script);\r\n}<\/pre>\n<ul>\n<ul>\n<li>Part-2: Defining the callback which gets the data and then updates the HTML<\/li>\n<\/ul>\n<\/ul>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">function listUnansweredQuestions(questions) {\r\n  var div = document.getElementById('questions');\r\n  var ul = document.createElement('ul');\r\n  div.appendChild(ul);\r\n  for (var i = 0; i &lt; questions.items.length; i++) {\r\n    var question = questions.items&#x5B;i];\r\n    var li = document.createElement('li');\r\n    li.innerHTML = '&lt;a href='+question.link+'&gt;'+question.title+'&lt;\/a&gt;';\r\n    ul.appendChild(li);\r\n  }\r\n}<\/pre>\n<p>The complete Javascript code would be:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\/\/sflow.js\r\nwindow.onload = function() {\r\n  var head = document.getElementsByTagName('head')&#x5B;0];\r\n  var script = document.createElement('script');\r\n\r\n  var url = 'https:\/\/api.stackexchange.com\/2.1\/questions\/unanswered?' +\r\n          'order=desc' +\r\n          '&amp;sort=activity' +\r\n          '&amp;tagged=jsonp' +\r\n          '&amp;site=stackoverflow' +\r\n          '&amp;callback=listUnansweredQuestions';\r\n\r\n  script.setAttribute('src', url);\r\n  head.appendChild(script);\r\n}\r\n\r\nfunction listUnansweredQuestions(questions) {\r\n  var div = document.getElementById('questions');\r\n  var ul = document.createElement('ul');\r\n  div.appendChild(ul);\r\n  for (var i = 0; i &lt; questions.items.length; i++) {\r\n    var question = questions.items&#x5B;i];\r\n    var li = document.createElement('li');\r\n    li.innerHTML = '&lt;a href='+question.link+'&gt;'+question.title+'&lt;\/a&gt;';\r\n    ul.appendChild(li);\r\n  }\r\n}<\/pre>\n<p>The output for the above HTML and Javascript would be:<\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/JSONP_result.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1285\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/JSONP_result.jpg\" alt=\"JSONP_result\" width=\"667\" height=\"572\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/JSONP_result.jpg 667w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/JSONP_result-300x257.jpg 300w\" sizes=\"(max-width: 667px) 100vw, 667px\" \/><\/a><\/p>\n<p>If you have any issues in running any of the sample code shown in the post above, please get in touch via the comments below.<\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td><span class=\"reference\">Reference: <\/span><\/td>\n<td><a href=\"http:\/\/blog.sanaulla.info\/2013\/08\/19\/getting-started-with-json-p\/\">Getting started with JSON-P<\/a> from our <a href=\"http:\/\/www.webcodegeeks.com\/wcg\/\">WCG partner<\/a> Mohamed Sanaulla at the <a href=\"http:\/\/blog.sanaulla.info\">Experiences Unlimited<\/a> blog.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>I have during my college days used XMLHttpRequest object and its equivalent in Microsoft world to make Ajax calls and those Ajax calls were to the URL within the same domain. But with the advent of Webservices and whole lot of mashups being developed, Ajax calls are not restricted to same domain but the cut &hellip;<\/p>\n","protected":false},"author":3,"featured_media":920,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[29],"class_list":["post-1096","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","tag-json-p"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Getting started with JSON-P - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"I have during my college days used XMLHttpRequest object and its equivalent in Microsoft world to make Ajax calls and those Ajax calls were to the URL\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/javascript\/getting-started-with-json-p\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Getting started with JSON-P - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"I have during my college days used XMLHttpRequest object and its equivalent in Microsoft world to make Ajax calls and those Ajax calls were to the URL\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/javascript\/getting-started-with-json-p\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2014-11-11T13:00:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Mohamed Sanaulla\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mohamed Sanaulla\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/getting-started-with-json-p\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/getting-started-with-json-p\/\"},\"author\":{\"name\":\"Mohamed Sanaulla\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/25d8251ab46cf28d12fa1ef1d02d22d1\"},\"headline\":\"Getting started with JSON-P\",\"datePublished\":\"2014-11-11T13:00:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/getting-started-with-json-p\/\"},\"wordCount\":1262,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/getting-started-with-json-p\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\",\"keywords\":[\"JSON-P\"],\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/getting-started-with-json-p\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/getting-started-with-json-p\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/javascript\/getting-started-with-json-p\/\",\"name\":\"Getting started with JSON-P - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/getting-started-with-json-p\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/getting-started-with-json-p\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\",\"datePublished\":\"2014-11-11T13:00:27+00:00\",\"description\":\"I have during my college days used XMLHttpRequest object and its equivalent in Microsoft world to make Ajax calls and those Ajax calls were to the URL\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/getting-started-with-json-p\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/getting-started-with-json-p\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/getting-started-with-json-p\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/getting-started-with-json-p\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Getting started with JSON-P\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/25d8251ab46cf28d12fa1ef1d02d22d1\",\"name\":\"Mohamed Sanaulla\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/64131fe9e9472b8852abf595cbbf3a8a2a5e86569fa1349eed92b2a32f9104c1?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/64131fe9e9472b8852abf595cbbf3a8a2a5e86569fa1349eed92b2a32f9104c1?s=96&d=mm&r=g\",\"caption\":\"Mohamed Sanaulla\"},\"sameAs\":[\"http:\/\/blog.sanaulla.info\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/mohamed-sanaulla\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Getting started with JSON-P - Web Code Geeks - 2026","description":"I have during my college days used XMLHttpRequest object and its equivalent in Microsoft world to make Ajax calls and those Ajax calls were to the URL","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/javascript\/getting-started-with-json-p\/","og_locale":"en_US","og_type":"article","og_title":"Getting started with JSON-P - Web Code Geeks - 2026","og_description":"I have during my college days used XMLHttpRequest object and its equivalent in Microsoft world to make Ajax calls and those Ajax calls were to the URL","og_url":"https:\/\/www.webcodegeeks.com\/javascript\/getting-started-with-json-p\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2014-11-11T13:00:27+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","type":"image\/jpeg"}],"author":"Mohamed Sanaulla","twitter_card":"summary_large_image","twitter_creator":"@webcodegeeks","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Mohamed Sanaulla","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/javascript\/getting-started-with-json-p\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/getting-started-with-json-p\/"},"author":{"name":"Mohamed Sanaulla","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/25d8251ab46cf28d12fa1ef1d02d22d1"},"headline":"Getting started with JSON-P","datePublished":"2014-11-11T13:00:27+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/getting-started-with-json-p\/"},"wordCount":1262,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/getting-started-with-json-p\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","keywords":["JSON-P"],"articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/javascript\/getting-started-with-json-p\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/javascript\/getting-started-with-json-p\/","url":"https:\/\/www.webcodegeeks.com\/javascript\/getting-started-with-json-p\/","name":"Getting started with JSON-P - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/getting-started-with-json-p\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/getting-started-with-json-p\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","datePublished":"2014-11-11T13:00:27+00:00","description":"I have during my college days used XMLHttpRequest object and its equivalent in Microsoft world to make Ajax calls and those Ajax calls were to the URL","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/getting-started-with-json-p\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/javascript\/getting-started-with-json-p\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/javascript\/getting-started-with-json-p\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/javascript\/getting-started-with-json-p\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"JavaScript","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/"},{"@type":"ListItem","position":3,"name":"Getting started with JSON-P"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/25d8251ab46cf28d12fa1ef1d02d22d1","name":"Mohamed Sanaulla","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/64131fe9e9472b8852abf595cbbf3a8a2a5e86569fa1349eed92b2a32f9104c1?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/64131fe9e9472b8852abf595cbbf3a8a2a5e86569fa1349eed92b2a32f9104c1?s=96&d=mm&r=g","caption":"Mohamed Sanaulla"},"sameAs":["http:\/\/blog.sanaulla.info"],"url":"https:\/\/www.webcodegeeks.com\/author\/mohamed-sanaulla\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/1096","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=1096"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/1096\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/920"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=1096"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=1096"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=1096"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}