{"id":328,"date":"2009-03-22T17:54:43","date_gmt":"2009-03-22T21:54:43","guid":{"rendered":"http:\/\/eligrey.com\/?p=328"},"modified":"2009-03-22T17:54:43","modified_gmt":"2009-03-22T21:54:43","slug":"pmxdr-postmessage-cross-domain-request-library","status":"publish","type":"post","link":"https:\/\/eligrey.com\/blog\/pmxdr-postmessage-cross-domain-request-library\/","title":{"rendered":"pmxdr: postMessage cross-domain request library"},"content":{"rendered":"<p><a href=\"http:\/\/github.com\/eligrey\/pmxdr\">pmxdr<\/a> is a cross-domain HTTP request JavaScript library. pmxdr stands for postMessage cross-domain requester. As the name implies, it makes use of the HTML5 postMessage API to make HTTP requests. It requires that a pmxdr host be on the target domain and it respects all HTTP access control headers, even on browsers that don\u2019t support them but do support postMessage, like Firefox 3.<\/p>\n<p>You can download the <a href=\"http:\/\/code.eligrey.com\/pmxdr\/client\/latest\">pmxdr client library<\/a> and the <a href=\"http:\/\/code.eligrey.com\/pmxdr\/host\/apache-package.zip\">pmxdr host library<\/a> (includes an example .htaccess file to help Apache users with PHP set it up) under the latest <a href=\"http:\/\/www.gnu.org\/copyleft\/gpl.html\">GNU GPL<\/a><a href=\"http:\/\/www.gnu.org\/licenses\/lgpl.html\"><\/a> license and an <a href=\"http:\/\/eligrey.com\/about\/license\/#mit-license\">MIT-style license<\/a>. The host library must be able to be accessed from \/pmxdr\/api to be able to interact with the client library.<\/p>\n<p>Read more at the <a href=\"http:\/\/github.com\/eligrey\/pmxdr\">pmxdr project page<\/a> and try out the <a href=\"http:\/\/code.eligrey.com\/pmxdr\/demo.html\">demo<\/a> of it in action.<\/p>\n<p>The following is a very simple example of how to use pmxdr to do a cross-domain POST request (impossible with the normal method of inserting a script tag):<\/p>\n<pre lang=\"javascript\">\/\/ The requesting domain is example.net\n\/\/ example.net doesn't want to give any control to example.com\npmxdr.request({\n  method   : \"post\",\n  uri      : \"http:\/\/example.com\/search.json\",\n  data     : \"q=foo\",\n  callback : loadSearchJSON\n})<\/pre>\n<p>Usually, in this hypothetical example, example.net would have to put a script tag with an src of http:\/\/example.com\/search.json?q=foo&amp;callback=loadSearchJSON and give example.com full control of example.net. This provides a secure cross-domain way to use APIs like this.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>pmxdr is a cross-domain HTTP request JavaScript library. pmxdr stands for postMessage cross-domain requester. As the name implies, it makes use of the HTML5 postMessage API to make HTTP requests. It requires that a pmxdr host be on the target domain and it respects all HTTP access control headers, even on browsers that don\u2019t support [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[76,78,90,91,129,131,188],"class_list":["post-328","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-html5","tag-http-access-controls","tag-javascript","tag-javascript-libraries","tag-pmxdr","tag-postmessage","tag-xdr"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pfpUD-5i","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/eligrey.com\/blog\/wp-json\/wp\/v2\/posts\/328","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eligrey.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eligrey.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eligrey.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/eligrey.com\/blog\/wp-json\/wp\/v2\/comments?post=328"}],"version-history":[{"count":0,"href":"https:\/\/eligrey.com\/blog\/wp-json\/wp\/v2\/posts\/328\/revisions"}],"wp:attachment":[{"href":"https:\/\/eligrey.com\/blog\/wp-json\/wp\/v2\/media?parent=328"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eligrey.com\/blog\/wp-json\/wp\/v2\/categories?post=328"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eligrey.com\/blog\/wp-json\/wp\/v2\/tags?post=328"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}