August 21, 2015
Morning puzzler
Here’s an uninteresting photo I took this morning:
Here’s my trick question:
Which way is up?
August 21, 2015
Here’s an uninteresting photo I took this morning:
Here’s my trick question:
Which way is up?
August 20, 2015
I to the world am like a drop of water
That in the ocean seeks another drop…
—Comedy of Errors1, II:1:199-200
Shakespeare is bringing before us both the vastness of the ocean and the indistinguishability of one drop from another, and maybe even the way in which drops in an ocean are artificial constructs. But for us, “a drop in the ocean” is the standard signifier of an amount so small that it makes no difference at all. A drop in the bucket could still add up to something. A drop in the ocean could not.
You can see the power of this image in the startling effect its inversion had in Kurt Vonnegut‘s Ice Nine. A single drop of this fictitious chemical would crystalize the entire ocean. Imagine, a mere drop in the ocean having such an effect!
Of course, when it comes to racism, for a long time in this country (and only this country), having one drop of “Negro” blood in your veins — a black ancestor in any generation back to the presumed-white Adam and Eve — was enough to make you subject to all of the racial and social restrictions white America had devised. [More] Unlike an ocean drop or bucket drop, a blood drop could make all the difference. But, racism is all about being inconsistent, so maybe we shouldn’t be surprised.
When it came to tiny bits that didn’t matter at all, a drop in the ocean was the measure.
Not any more. All those drops have added up. Depending on where you’re floating, if you were to withdraw a drop from the ocean, there’s a measurable probability that you’ll come down with hepatitis. In some parts of the ocean, your dropper will get clogged with plastic. No drops for you.
We used to say that the ocean is forgiving. It turns out it was just nursing a grudge.
We have suffered from the Fallacy of Scale. We are now learning the power of drops. Perhaps too late.
1Speaking of Comedy of Errors, don’t miss the hilarious version at Shakespeare & Co. in Lenox, Mass. It’s set in NJ, and they play it entirely for laughs because, well, it’s a comedy.
August 18, 2015
The New Atlantis has just published five essays exploring “The Unknown Newton”. It is — bless its heart! — open access. Here’s the table of contents:
Rob Iliffe provides an overview of Newton’s religious thought, including his radically unorthodox theology.
William R. Newman examines the scientific ambitions in Newton’s alchemical labors, which are often written off as deviations from science.
Stephen D. Snobelen — who in the course of writing his essay discovered Newton’s personal, dog-eared copy of a book that had been lost — provides an in-depth look at the connection between Newton’s interpretation of biblical prophecy and his cosmological views.
Andrew Janiak explains how Newton reconciled the apparent tensions between the Bible and the new view of the world described by physics.
Finally, Sarah Dry describes the curious fate of Newton’s unpublished papers, showing what they mean for our understanding of the man and why they remained hidden for so long.
Stephen Snobelen’s article, “Cosmos and Apocalypse,” begins with a paper in the John Locke collection at the Bodelian: Newton’s hand-drawn timeline of the events in Revelations. Snobelen argues that we’ve read too much of The Enlightenment back into Newton.
In particular, the concept of the universe as a pure clockwork that forever operates according to mechanical laws comes from Laplace, not Newton, says Snobelen. He refers to David Kubrin’s 1967 paper “Newton and the Cyclical Cosmos“; it is not open access. (Sign up for free with Jstor and you get constrained access to its many riches.) Kubrin’s paper is a great piece of work. He makes the case — convincingly to an amateur like me — that Newton and many of his cohorts feared that a perfectly clockwork universe that did not need Divine intervention to operate would be seen as also not needing God to start up. Newton instead thought that without God’s intervention, the universe would wind down. He hypothesized that comets — newly discovered — were God’s way of refreshing the Universe.
The second half of the Kubrin article is about the extent to which Newton’s late cosmogeny was shaped by his Biblical commitments. Most of Snobelen’s article is about a discovery in 2004 of a new document that confirms this, and adds to it that God’s intervention heads the universe in a particular direction:
In sum, Newton’s universe winds down, but God also renews it and ensures that it is going somewhere. The analogy of the clockwork universe so often applied to Newton in popular science publications, some of them even written by scientists and scholars, turns out to be wholly unfitting for his biblically informed cosmology.
Snobelen attributes this to Newton’s recognition that the universe consists of forces all acting on one another at the same time:
Newton realized that universal gravity signaled the end of Kepler’s stable orbits along perfect ellipses. These regular geometric forms might work in theory and in a two-body system, but not in the real cosmos where many more bodies are involved.
To maintain the order represented by perfect ellipses required nudges and corrections that only a Deity could accomplish.
Snobelen points out that the idea of the universe as a clockwork was more Leibniz’s idea than Newton’s. Newton rejected it. Leibniz got God into the universe through a far odder idea than as the Pitcher of Comets: souls (“monads”) experience inhabiting a shared space in which causality obtains only because God coordinatis a string of experiences in perfect sync across all the monads.
“Newton’s so-called clockwork universe is hardly timeless, regular, and machine-like,” writes Snobelen. “[I]nstead, it acts more like an organism that is subject to ongoing growth, decay, and renewal.” I’m not sold on the “organism” metaphor based on Snobelen’s evidence, but that tiny point aside, this is a fascinating article.
August 17, 2015
I got a little interested in the question of Isaac Newton’s connection to astrology because of something I’ve been working about casuality. After all, Newton pursued alchemical studies with great seriousness. And he gave us a theory of action at a distance that I thought might be taken as providing a rationale for astrological effects.
But, no. According to a post by Graham Bates:
In a library of 1763 books, (1752 different titles excluding duplicates) he had 369 books on what we would call scientific subjects, plus 169 on Alchemy (including many of the important texts on the subject copied in his own hand), there were also 477 books on Theology. He possessed only four books on astrology; two of these were treatises on astrology, one was an almanac, and one was a refutation of astrology
Bates says that a book on astrology that he purchased as a boy led him to learn about Euclid’s theorems so he could construct an astrologocial chart, but that is the extent of his known interest.
Bates also does a good job tracking down a spurious quote:
There is a story, much quoted in astrological articles and books, about a dispute between Newton and Halley (of the comet fame), supposedly about astrology, in which Newton replies to a remark by Halley “I have studied these things, you have not”.
The actual quote refers to theology, not astrology. So, no, Newton was not practitioner of astrology and there’s no reason to think that he gave it any credence. (Me neither, by the way.)
The post is on the Urania Trust site, which I had not heard of before. The group was founded in 1970 “to further the advancement of education by the teaching of the relationship between main’s [sic] knowledge of, beliefs about, the heavens and every aspect of his art science philosophy and religion.” Given its commitment to taking astrology seriously, the fairness of its post about Newton is admirable.
(Now if I could only find out if Newton played billiards.)
August 13, 2015
I just came across an article from my old JOHO newsletter, from May 2005, that I wrote for Esther Dyson’s Reality 1.0. It was titled Trees and Tags— An Introduction, and it was about the limitations of taxonomies and the rise of tags. I must have been writing or researching Everything Is Miscellaneous at the time.
Here’s the introductory section. If you’re interested in ancient history, you can read the whole thing.
The narrative that tells of the first man and woman encountering the tree of knowledge focuses on its tempting fruit. But after we took the bite, we apparently looked up and got the idea that knowledge is shaped like the tree’s branching structure: Big concepts contain smaller ones that contain smaller ones yet. Over the millennia, we have fashioned the structures of knowledge in just such tree-like ways, from the departmental organization of universities (liberal arts contains history and history contains ancient Chinese history) to the hierarchy of species. The idea that knowledge is shaped like a tree is perhaps our oldest knowledge about knowledge.
Now autumn has come to the forest of knowledge, thanks to the digital revolution. The leaves are falling and the trees are looking bare. We are discovering that traditional knowledge hierarchies that have served us so well are unnecessarily restricted when it comes to organizing information in the digital world. The principles of organization themselves are changing now that they are being freed from the constraints of the physical world. For example:
In the physical world, a fruit can hang from only one branch. In the digital world, objects can easily be classified in dozens or even hundreds of different categories.
In the real world, multiple people use any one tree. In the digital world, there can be a different tree for each person.
In the real world, the person who owns the information generally also owns and controls the tree that organizes that information. In the digital world, users can control the organization of information owned by others. (Exception to the rule: Westlaw owns the standard organization of case law even though the case law itself is in the public domain.)
These differences are so substantial that we can think of intellectual order as entering a third age. In the first, we organized the things themselves: We put books on shelves and silverware into drawers. In the second, we physically separated the metadata from the data: We built card catalogs and drew diagrams. In the third, the data and the metadata are digital, untying organization from the strictures of the physical world. In response, we are rapidly inventing new principles and tools of organization. When it comes to innovation on the Internet, metadata is becoming the new content.
But traditional taxonomic trees aren’t something we can throw away without a thought. They are an amazingly efficient way of organizing complexity because they enable us to focus on one aspect (e.g., that’s an apple) while keeping a universe of context (it’s a fruit, part of a plant, a type of living thing) in the background, ready for access. Tree structures are built into our institutions. They may even be built into our genes. So we are in a confusing and fertile period as we try to sort out what works and what doesn’t. Without trees, how would we organize college curricula, business org charts, the local library, and the order of species? How will we organize knowledge itself?
We may be on the path to finding out.
August 12, 2015
When we slept in caves
did we ever sleep all night?
With the bears aware outside
And the snakes wound up tight?
With no blanket but your pal
And a pillow made of naught
It’s hard indeed to believe
any winks at all were caught.
But now we act as if
we’ve a right to sleep right through
the cries of tots and shouts and shots,
— if not, we’ll find someone to sue.
What’s natural is that we stayed up.
A good night’s sleep is all made up.
August 11, 2015
The British Library has posted one million public domain images — images not subject to any copyright restrictions — at Flickr. (They did this at least a year ago, but it’s still worth noting, isn’t it?)
The public can view them, copy them, and reuse them freely in every regard. An article in Quartz by Anne Quito reports:
So far, these images, which range from Restoration-era cartoons to colonial explorers’ early photographs, have been used on rugs, album covers, gift tags, a mapping project, and an art installation at the Burning Man festival in Nevada, among other things.
The Library posted them not only so they could be enjoyed and reused, but so the public would do what the Library is not staffed to do all by itself: add tags. Says Quartz:
to date, the collection has garnered over 267 million views, and over 400,000 tags have been added to images on Flickr by users. Through a “tagathon” with the Wikimedia UK community, the Library discovered over 50,000 maps in the collection, which they are now in the process of fitting into a modern map.
I can’t figure out how to search within a collection at Flickr, but this view at least does some clustering.
August 10, 2015
The Wall Street Journal has run an article by Robert Lee Hotz that gently ridicules scientists for including thousands of people as co-authors of some scientific publications. Sure, a list of 2,000 co-authors is risible. But the article misses some of the reasons why it’s not.
As Robert Lee points out, “experiments have gotten more complicated.” But not just by a little. How many people did it take to find the Higgs Boson particle? In fact, as Michael Nielsen (author of the excellent Reinventing Discovery) says, how many people does it take to know that it’s been found? That knowledge depends on deep knowledge in multiple fields, spread across many institutions and countries.
In 2012 I liveblogged a fantastic talk by Peter Galison on this topic. He pointed to an additional reason: it used to be that engineers were looked upon as mere technicians, an attitude mirrored in The Big Bang (the comedy show, not the creation of the universe—so easy to get those two confused!). Over time, the role of engineers has been increasingly appreciated. They are now often listed as co-authors.
In an age in which knowledge quite visibly is too big to be known by individuals, sharing credit widely more accurate reflects its structure.
In fact, it becomes an interesting challenge to figure out how to structure metadata about co-authors so that it captures more than name and institution and does so in ways that make it interoperable. This is something that my friend Amy Brand has been working on. Amy, recently named head of the MIT University Press is going to be a Berkman Fellow this year, so I hope this topic will be a subject of discussion at the Center.
August 8, 2015
The Gregory Brothers at it again. Please enjoy not just ridiculousness of what they’re parodying, but the musicality of what they’ve produced and in such short order:
Personally, I want to see the Trump meme “We need brain” not just songified but also zombified: “WE…NEED…BRAIN. WE…NEED…BRAAAAIN.
August 4, 2015
Perhaps you’d like to post to your WordPress blog from an app that isn’t WordPress.
I know I do. I write most of my posts in an editor (javascript + php) I’ve worked on for over ten years. Someday I’ll clean it up and post it at GitHub so you can all have a laugh. Meanwhile, it intermittently loses its ability to post straight to my blog, so I have to copy and paste the text into the WP editor. But I fixed it again today. So, here’s a tutorial for people at my level of non-technicality. (I got huge help from a post at HurricaneSoftware. Thanks!)
First, make sure that the file xmlrpc.php is installed where you’ve installed your WordPress blog software. This file comes from WordPress itself, and it should be there automatically. Check the permissions; I think it should be 644 but I am terrible at permissions.
I run my homegrown editor from my Mac, using the Apache web server that MAMP supplies. That lets me write blog posts even when I’m not online. That means the directory from which I’m running my JavaScript and PHP is on my hard drive. I keep these files in /Applications/MAMP/htdocs/blogdraft/. (Blogdraft is the name of the folder in which my code resides.) To the web server, the address looks like this: /localhost/blogdraft/.
The operative part of this is your PHP file. Create an empty text file and name it, let’s say, postViaXmlrcp.php. For a first pass, it should look like this—and the brunt of this comes straight from HurricaneSoftware:
1 |
<?php |
2 |
// Modified from: |
3 |
// http://www.hurricanesoftwares.com/wordpress-xmlrpc-posting-content-from-outside-wordpress-admin-panel/ |
4 |
// Thanks!! |
|
|
5 |
require_once(“IXR_Library.php.inc”); |
6 |
$client->debug = true; //Set it to false in Production Environment |
7 |
$title=$_REQUEST[‘title’]; |
8 |
$body=$_REQUEST[‘body’]; |
9 |
$keywords=$_REQUEST[‘tags’]; |
10 |
$category=$_REQUEST[‘categoryArray’]; |
11 |
$customfields=null; |
|
|
12 |
$encoding = ini_get(“default_charset”); |
13 |
$title = htmlentities($title,ENT_QUOTES,$encoding); |
14 |
$keywords = htmlentities($keywords,ENT_QUOTES,$encoding); |
|
|
15 |
$content = array( |
16 |
‘title’=>$title, |
17 |
‘description’=>$body, |
18 |
‘mt_allow_comments’=>1, // 1 to allow comments |
19 |
‘mt_allow_pings’=>1, // 1 to allow trackbacks |
20 |
‘post_type’=>’post’, |
21 |
‘mt_keywords’=>$keywords, |
22 |
‘categories’=>$category, |
23 |
‘custom_fields’ => array($customfields) |
24 |
); |
|
|
25 |
// Create the client object |
26 |
$client = new IXR_Client(‘http://www.yourblog.com/myWP/xmlrpc.php’); |
27 |
$username = “your-WP-username”; |
28 |
$password = “your-WP-password”; |
|
|
29 |
$params = array(0,$username,$password,$content,true); // Last parameter is ‘true’ which means post immediately, to save as draft set it as ‘false’ |
|
|
30 |
// Run a query for PHP |
31 |
if (!$client->query(‘metaWeblog.newPost’, $params)) { |
32 |
die(‘Something went wrong – ‘.$client->getErrorCode().’ : ‘.$client->getErrorMessage()); |
33 |
} else { echo “Article Posted Successfully”; } |
34 |
?> |
This PHP script relies upon another one, so you have to load it. “Require_once” will do so, and it will remember that it has done so during a session so you won’t waste computer resources reloading it every time you run this script.
You can get this script here. Right click on that link and choose “Save file as…” or however your browser puts it. Put it in the same directory as your PHP script. Make sure you name it “IXR_Librabry.php.inc.” Set its permissions. (See above.) Then leave it alone.
7 |
$title=$_REQUEST[‘title’]; |
8 |
$body=$_REQUEST[‘body’]; |
9 |
$keywords=$_REQUEST[‘tags’]; |
10 |
$category=$_REQUEST[‘categoryArray’]; |
11 |
$customfields=null; |
These lines read data that you’ve sent from the JavaScript that we haven’t written yet. It assigns them to some pretty obviously-named PHP variables.
Notice that we’re doing nothing with the $customfields variable. That’s because I don’t know what to do with it. I would have just deleted that line, but it scares me. And yet fascinates me.
12 |
$encoding = ini_get(“default_charset”); |
13 |
$title = htmlentities($title,ENT_QUOTES,$encoding); |
14 |
$keywords = htmlentities($keywords,ENT_QUOTES,$encoding); |
htmlentities is a PHP function that makes sure that your HTML with all of its weird characters arrive without being translated into something more literal and wrong. Line 12 tells it which character encoding to use. I could have decided on one for you, but instead I’m just using whichever one you already use. We have already established I’m a coward, right?
15 |
$content = array( |
16 |
‘title’=>$title, |
17 |
‘description’=>$body, |
18 |
‘mt_allow_comments’=>1, // 1 to allow comments |
19 |
‘mt_allow_pings’=>1, // 1 to allow trackbacks |
20 |
‘post_type’=>’post’, |
21 |
‘mt_keywords’=>$keywords, |
22 |
‘categories’=>$category, |
23 |
‘custom_fields’ => array($customfields) |
24 |
); |
We are eventually going to be sending all of the content information to WordPress via XMLRPC. This section packs an array (“$content”) with the information XMLRPC needs, attached to the keywords it loves. If you want to argue about it, take it up with XMLRPC.
26 |
$client = new IXR_Client(‘http://www.yourblog.com/myWP/xmlrpc.php’); |
We now create a new client for the IXR script you downloaded. It wants to know where your xmlrpc.php file is, which should be where the rest of your WordPress files are folders are.
27 |
$username = “your-WP-username”; |
28 |
$password = “your-WP-password”; |
Fill in your WordPress username and password.
29 |
$params = array(0,$username,$password,$content,true); // Last parameter is ‘true’ which means post immediately, to save as draft set it as ‘false’ |
Now we’re making another array. This one includes the prior array ($content) as well as your username and password. And note the comment. Setting to “draft” is very useful when you’re playing around with these scripts.
31 |
if (!$client->query(‘metaWeblog.newPost’, $params)) { |
32 |
die(‘Something went wrong – ‘.$client->getErrorCode().’ : ‘.$client->getErrorMessage()); |
33 |
} else { echo “Article Posted Successfully”; } ?> |
This does the deed. No one knows how. If it fails, it’ll pop up the error messages and kill it before it spawns evil. Otherwise, it sends back the message that it posted successfully.
You can test this PHP script by running it in your browser. If you’re running a local web server, you’d enter something like this: /localhost/blogdraft/postViaXmlrcp.php. (That’s assuming you put it in a folder called “blogdraft,” of course.) Check with MAMP or whatever you’re using for your web server for details.
But running this as-is won’t work because it’s expecting the content to be sent to it from the JavaScript we still haven’t written. So, comment out lines #7-11, and insert something like these:
$title=”TEST TITLE”; |
|
$body=”<h1>Hello, world!</h1>” |
|
$keywords=”tag1,tag2″ |
|
$category=array(“cat1″,”cat2”); |
|
$customfields=null; |
Replace the categories (“cat1”, “cat2”) with the names of categories that you actually use. Also, change “true” to “false” in line #29 so you’ll just produce drafts, not actually publish anything yet.
Now when you run this PHP file in your browser ( /localhost/yourLocalFolder/postViaXmlrcp.php), if should create a draft post. Check via the “All posts” page at your WP administration page to see if the draft got created.
When it’s working, comment out the four lines immediately above and uncomment lines #7-11.
The JavaScript
I’m going to pretend that you have some HTML page that has a text box where you can enter the content of your post, a similar box for entering the title, one for entering tags separated by commas, and checkboxes that list the categories you use. I’ll also assume that you use jQuery. So, your HTML might look soomething like this:
1 |
<!DOCTYPE html> |
2 |
<html lang=”en”> |
3 |
<head> |
4 |
<meta charset=”utf-8″ /> |
5 |
<title>WordPress poster tester</title> |
6 |
<script src=”https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js”></script> |
|
|
7 |
<script> |
8 |
function postIt(){ |
9 |
// get the title |
10 |
var titlecontent = $(“#titlebox”).val(); |
11 |
// get the body of the post |
12 |
var bodycontent = $(“#contentbox”).val(); |
13 |
// get the tags |
14 |
var tagscontent = $(“#tagsbox”).val(); |
|
|
15 |
// create array of categories |
16 |
// get an array of all checkboxes in the div |
17 |
var checks = $(“#categories”).find(“input”); |
18 |
// create an empty array |
19 |
var cats = new Array(); |
20 |
// go through all the checkboxes |
21 |
for (var i=0; i < checks.length; i++){ |
22 |
// is this one checked? |
23 |
if ($(checks[i]).is(‘:checked’)){ |
24 |
// if so, then push its value into the array |
25 |
cats.push( $(checks[i]).val() ); |
26 |
} |
27 |
} |
28 |
// run the php |
29 |
$.ajax({ |
30 |
type: “POST”, |
31 |
url: “postViaXmlrcp.php”, |
32 |
dataType: JSON, |
33 |
data: {title: titlecontent, body : bodycontent, tags: tagscontent, categoryArray : cats}, |
34 |
error: function(e){ |
35 |
if (e.responseText.indexOf(“Successfully”) > -1){ |
36 |
alert(“Success! Post has been posted! Let the regrets begin!”); |
37 |
} |
38 |
else{ |
39 |
alert(‘Error posting blog via xmlrpc: ‘ + e.responseText); |
40 |
} |
41 |
} |
42 |
}) |
43 |
} |
44 |
</script> |
|
|
|
|
45 |
</head> |
46 |
<body> |
47 |
<textarea id=”titlebox”>test title</textarea> |
48 |
<textarea id=”contentbox”><h1>got some content here</h1></textarea> |
49 |
<textarea id=”tagsbox”>tag1, tag2</textarea> |
50 |
<div id=”categories”> |
51 |
<input value=”business” type=”checkbox” checked>Cats |
52 |
<input value=”dogs” type=”checkbox”>Dogs |
53 |
<input value=”philosophy” type=”checkbox”>Phenomenology |
54 |
</div> |
55 |
<input type=”button” value=”Post It!” onclick=”postIt()”> |
56 |
</body> |
57 |
</html> |
So, roughly, here’s what’s happening:
6 |
<script src=”https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js”></script> |
This loads jQuery from Google. Of course you could keep a local copy and include it that way.
8 |
function postIt(){ |
9 |
// get the title |
10 |
var titlecontent = $(“#titlebox”).val(); |
11 |
// get the body of the post |
12 |
var bodycontent = $(“#contentbox”).val(); |
13 |
// get the tags |
14 |
var tagscontent = $(“#tagsbox”).val(); |
The postIt function begins by using jQuery to fetch the values entered into the three text areas. (Just in case you don’t know jQuery, “$(“#titlebox”) gets the element with the ID of “titlebox.” And if you don’t want to use jQuery, you can get the same result with: var titlecontent = document.getElementById(‘titlebox’).value.
16 |
// get an array of all checkboxes in the div |
17 |
var checks = $(“#categories”).find(“input”); |
18 |
// create an empty array |
19 |
var cats = new Array(); |
20 |
// go through all the checkboxes |
21 |
for (var i=0; i < checks.length; i++){ |
22 |
// is this one checked? |
23 |
if ($(checks[i]).is(‘:checked’)){ |
24 |
// if so, then push its value into the array |
25 |
cats.push( $(checks[i]).val() ); |
26 |
} |
27 |
} |
Creating an array of categories takes a little more work. Line #17 creates an array (“checks”) of all of the checkboxes in the div with the id “categories.” Lines #21-27 look at each of the checkboxes in that array. If line #23 sees that a particular checkbox has in fact been checked, then it puts the value of that checkbox into the created on line #19. (You want the value to be exactly the same as the name of the category in your WordPress installation. Also, remember that the checkbox’s value is not necessarily the same as the text displayed to the user.)
29 |
$.ajax({ |
30 |
type: “POST”, |
31 |
url: “postViaXmlrcp.php”, |
32 |
dataType: JSON, |
33 |
data: {title: titlecontent, body : bodycontent, tags: tagscontent, categoryArray : cats}, |
34 |
error: function(e){ |
35 |
if (e.responseText.indexOf(“Successfully”) > -1){ |
36 |
alert(“Success! Post has been posted! Let the regrets begin!”); |
37 |
} |
38 |
else{ |
39 |
alert(‘Error posting blog via xmlrpc: ‘ + e.responseText); |
40 |
} |
41 |
} |
42 |
}) |
Now we call the PHP script that we created above. We do this via AJAX, using the jQuery syntax, which is much simpler than the native JavaScript way of doing it. Lines #30-40 specify the communication the JavaScript will have with the PHP file.
Line #30: The “POST” here has nothing to do with posting a blog post. It’s stating what sort of transaction we’re about to have with the PHP script.
Line #31: This is the path to the PHP file we’re going to run. If it’s in the same directory as this HTML file, you don’t have to monkey with a path name.
Line #32: We’re going to pass data to the PHP script in the JSON way of expressing data.
Line #33: This creates the JSON we’re going to send. It’s all within curly brackets. There are four phrases, separated by commas. Each phrase consists of a keyword (which you can think of as being like a variable) and a value. We are free to make up whatever keywords we want, so long as those are the keywords we use in the PHP file to fetch the data that they label; see lines #7-10 in the PHP script above.
Line #44: If there is an error in the PHP, it will send back some information. There is also an equivalent “success:” function available. But I’m doing something wrong, because even when the PHP works and the blog gets posted, I still get an error message. If you go back to Line #33 of the PHP, you’ll see that if the PHP succeeds, it sends the message “Article Posted Successfully.” For reasons I don’t understand, that message shows up in the “error:” function of the AJAX. So, I check the message. If it has the word “Successfully” in it, the script alerts the user that the post has been posted. If it does not, on line #39 it posts an error message.
That’s it. If it doesn’t work, it’s because you’re doing something wrong, starting with listening to me. Obviously I can’t help you since I don’t even know how this thing works.
Good luck!