The function admin-post.php not receiving all of the data sent to it.
-
I am attempting to post a JSON encoded string to the server using XMLHttpRequest and admin-post.php. This string is quite long representing about 80 fields on a DB record edit screen. I append three fields to the formdata object. I get the data for two of them but the one that is supposed to hold the JSON encoded string will is not received at admin-post.php. It just is null. I can see in the debugger that the string is being sent but cannot for the life of me figure out where it goes. I am also having problems doing a regular post of the form as well.
Here is the Javascript part:
function dbSaveOnClick(e) { var formData = new FormData(); var dbRequest = new XMLHttpRequest(); var data = {}; var postobj = ""; var recordId = 0; for(a=0;a<document.getElementById('dbForm').elements.length;a++) { switch(document.getElementById('dbForm').elements[a].id) { case "dbAttributes": case "dbSave": case "dbCancel": case "dbNULL": case "": break; default: data[document.getElementById('dbForm').elements[a].id] = document.getElementById('dbForm').elements[a].value; break; } } postobj = JSON.stringify(data); formData.append("action", "upload_form_data"); formData.append("id", recordId); formData.append("fielddata", postobj); dbRequest.onreadystatechange = dbSaveOnReadyStateChange; dbRequest.open('POST', "/wp-admin/admin-post.php", true); dbRequest.send(formData); }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘The function admin-post.php not receiving all of the data sent to it.’ is closed to new replies.