I did some research on this topic but i cant run this id is not send to page.
listdata.php
<td class="text-center" style="min-width:130px;">
<button style="width:100%" class="btn btn-primary detail-customer" data-id="<?php echo $m->id; ?>">Bilgi</button>
</td>
ajax.php
$(document).on("click", ".detail-customer", function() {
var id = $(this).attr("data-id");
$.ajax({
method: "POST",
url: "<?php echo base_url('customers/info'); ?>",
data: "id=" + id
})
.done(function(data) {
window.location = "customers/info";
})
})
controller:
public function info()
{
$data['page'] = "customer_information";
$data['userdata'] = $this->userdata;
$id= trim($_POST['id']);
print $id;
//$this->template->views('customers/info', $data);
}
2
Answers
Are you naming your ajax file as
Ajax.php
? is that aPHP
file? It definitely should be ajs
file.From what I know from Jquery and Ajax,
url
key takes the location of the PHP file, and thedata
key should be passed as an object. Take these two files as an example:Ajax.js
Php_file.php
This is a very basic example of how to use ajax.
Please try it
"we do not read your complete controller code
if your code is correct total then please
first convert data in json then
return it.
"