I am testing wireit and am able to create new form containers and such. I tested the ajax adapter example and have it configed something like:
WireIt.WiringEditor.adapters.Ajax.config = {
saveWiring: {
method: 'PUT',
url: 'http://voipd7.localhost/wirings.json'
},
deleteWiring: {
method: 'GET',
url: function(value) {
if(console && console.log) {
console.log(value);
}
// for a REST query you might want to send a DELETE /resource/wirings/moduleName
return "fakeSaveDelete.json";
}
},
listWirings: {
method: 'GET',
url: 'listWirings.json'
}
The save url “http://voipd7.localhost/wirings.json” is a php page that just writes the $_GET or $_Post to file, but the only thing that it outputs is:
Array
(
[q] => wirings.json
)
Am I missing something? Shouldnt this be sending json stuff via get or post?
From the provided configuration, it is evident that the HTTP method for doing a save operation is
PUT. When using this method, the superglobal variables$_POSTor$_REQUESTdo not contain the posted data.$_GETwill still have the data from the query string.To parse the posted data when the method is
PUT, do some of the following:The
PUTmethod expects to receive file as input. That is why we usefile_get_contentsandparse_strparses the argument as if it were the query string passed via a URL. To extract the data variables regardless of the method use:I based the reply on this very nice article: http://www.lornajane.net/posts/2008/accessing-incoming-put-data-from-php
One note: usually the web server is configured not to allow PUT methods but when it sees (at least Apache does this) that the PUT request is for an existing file, it calls this file to handle the request and the above code can be used in the file to extract the sent parameters.