I have the below code:
var formData = {};
formData['client_exists'] = 1;
formData['client_id'] = 1234;
formData['subdata'] = subdata;
This builds up an object, subdata is a multidimensional array.
I then try to pass it off to my controller with the following:
let xhr = new XMLHttpRequest(), self = this;
window.location = window.location.origin+'/'+formAction+'/' + formData;
Note that I cannot use the below format as it causes an encoding issue with the pdf generation
$.ajax({
type : formMethod,
url : formAction,
data : formData,
cache : false,
success : function(data) {
}
});
When it gets to my controller I only get an empty array as my formData is passed through as this in the url:
[object%20Object]
I cant't figure out how to pass this through correctly, If i use JSON.stringify -
window.location = window.location.origin+'/'+formAction+'/?' + JSON.stringify(formData);
i get the data through however it isn't in a usable format:
array:1 [▼
"{"client_exists":1,"client_id":123,"subdata":" => array:1 [▼
"{"something":"111","something_else":"222","something_more":"333"}" => ""
]
]
Is there a better way for me to pass this through or a way I can format it into a proper multidimensional array on the back-end (PHP)?