Reputation: 67
I have this line for delete a folder
<button class='elimina' data-elimina='$path/$file'>elimina $path/$file</button>
get the folder path via JQuery
$(".elimina").click(function(){
var data = $(this).data('elimina');
$.post('file.php',data, function(response) {
// Log the response to the console
console.log("Response: "+response);
});
});
At the last I pass it to my file.php
$archivo = $_POST['data'];
rmdir($archivo);
But never got pass the var data to my php file .I put an if(isset($_POST['data'])){echo $_POST['data'];} and never saw the path,but I now the path arrive to Jquery script (because also tested).
I haven´t form,only the button,could be it the problem?
Upvotes: 1
Views: 804
Reputation: 360572
This is wrong:
$.post('file.php',data, function(response) {
^^^^
You're not sending a key:value
pair, you're just sending value
. With no key, PHP has nothing to use to produce a $_POST entry
You should have
$.post('file.php',{data:data}, function(response) {
^-key ^--value
Upvotes: 1