Here I'm attaching the image of my code. I need to post an id to the same page when I clicking a link, and also need to pop-up a bootstrap model window. I'm worked with several methods. The value is available at console and fire bug inspect. But I could not get the id using $_GET
,$_POST
or $_REQUEST
methods. Any Can you help me?
<td><p data-placement="top" data-toggle="tooltip" title="Edit"><button class="btn btn-primary btn-xs" data-title="Edit" data-toggle="modal" data-target="#edit" id="edit-button" data-id="26" ><span class="fa fa-pencil"></span></button></p></td>
<script>
$('#edit-button').click(function(){
var eid = $(this).data('id');
$.ajax
({
url: 'managers.php',
data: {"eid": eid},
type: 'post',
success: function(result)
{
console.log(eid);
}
});
});
</script>
It appears that the ajax request succeeds but returns the entire page rather than the specific data you need. To alleviate this check for the request method (POST) and for the existence of the particular variable (eid) and, before sending any data back, clear the output buffer (ob_clean) - proceed with processing and then exit/die.
Complete example of returning only required data rather than entire page.