Via asynchronous HTTP requests, I can use an existing service to load/save some information from/into a database. But these requests (AJAX) can be done, at least as far as I know, only from the client-side (e.g. a JavaScript script).
E.g. using jQuery ajax method:
$.ajax({
type: "POST",
url: someurl,
dataType: 'xml',
data: xmlString,
success: function(data) {
// some code here
}
});
How can use the same service from a PHP script? That is, how can I “make an AJAX call from PHP”, using either the POST or GET methods?
You can use cURL library to access the same URL.
You will possibly need to set the “X-Requested-With” header to “XMLHttpRequest” in case the receiving service checks.
Otherwise, proceed as in this answer except that you will be using the POST commented fields.
This answer suggests how to debug and reverse engineer an existing AJAX service. Then, you will be able to use e.g. SimpleXML to decode the answer, which, from the jQuery code you posted, will come through in XML format.
A TEST.