Problem with custom plugin using AJAX to pull info from php file
I’m extremely frustrated over what I expected to be an easy task.
I have a wordpress plugin that I’m looking to do the following (with woocommerce) —
- Customer adds a product to cart.
- I get the response from myfile.php, then i could manipulate that data as needed.
When i do this my normal way, i get a file not found, but i can access it directly.
I’ve done this many times in the past, without wordpress, with no issue. Now i’m seeing things about needing to use admin-ajax as some sort of intemediary?? compounding that, all examples have things about adding in add’l JS files, which I’m not looking to do. I just want the JS added to the footer to look at a php file, then use that php files content elsewhere.
I’ve stripped down my code below. It’s not exactly my original intent, i just plan on moving the sccrirpt in myfile.php to the my_action function. It returns a 400 error after many different attempts. can anyone point me in the right direction?