Hey everyone I’m having some trouble sending single variables or an object into PHP.
When I send a json object from my JS to PHP, the error i receive back is just “undefined”, and on the console, when I type in the variable jsonFile, which stringifies the object I want to send, it says “jsonFile is undefined”
The error method doesn’t receive an actual error object as its 1st argument but the XMLHttpRequest that was sent, and that doesn’t have a .message property – hence it is undefined. Try something like this instead
Well judging from that lonely closing brace at the end of your code the jsonFile variable isn’t declared in the global scope, but probably some sort of event handler function; so you can’t just access it at any point from the console. You can however set a breakpoint inside that function and then inspect the variables in its scope (and actually access them from the console).
When I did this, my console brings back ok, so i changed it to status and it brings back “200” which is for loading or done, however this is in the error:function, so im kinda confused as to why a “loading done” status would only appear at the error