I am trying do make something with x-editable for bootstrap. When I am done editing and click enter, the url page doesn't show anything (there is a print_r, which gives me an empty array) Code here:
X-editable:
<a class="edit" data-type="text" data-pk="1" data-name="name" data-url="post.php">test</a>
<script>
$(document).ready(function() {
$.fn.editable.defaults.mode = 'inline';
$('.edit').editable({
ajaxOptions: {
type: 'post'
},
success: function(response, newValue) {
console.log(response);
},
error: function(response, newValue) {
window.alert('failed');
}
});
});
</script>
post.php:
$id = $_POST['pk'];
$name = $_POST['name'];
$value = $_POST['value'];
print_r($_POST);
Response in console:
Array
(
)
Change the type attribute to post
You are using the HTTP PUT method in your ajax request. If you really want to do it like this, you have to read it differently on the PHP side, that is, from STDIN, see PUT support in the PHP manual.
If you do not insist on using PUT as a method, you could change it to POST and then should consequently also get something in your $_POST superglobals.