I want to pass a data data: ( {name: 'ccenter', value: 'Sales Department' } ) using AJAX JQuery into PHP page Without any submission.
I try with session_name(); session_start(); But It didn't work.variable $ccenter still remains undefined.I think i have missed some code to do so.please help me.Thanks
Here Is my Jquery AJAX Code:
$(function () {
$.ajax({
url: 'empid_list.php',
type: "post",
async:true,
data: ( {name: 'ccenter', value: 'Sales Department' } ),
dataType: 'html',
success: function(data) {
$('#employeeid').html(data);
}
});
});
And Here Is my PHP File code:
<?php
session_name('session1');
session_start();
$ccenter = $_POST['ccenter'];
?>
$_POST['name']instead of$_POST['center'](because of key -> value association) and you should echo something back from php, elsedatawill beundefined.