user5005768 user5005768 - 4 months ago 7x
Ajax Question

How to pass Data From JQuery AJAX to PHP Without submit

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
still remains undefined.I think i have missed some code to do so.please help me.Thanks

Here Is my Jquery AJAX Code:

$(function () {

url: 'empid_list.php',
type: "post",
data: ( {name: 'ccenter', value: 'Sales Department' } ),
dataType: 'html',
success: function(data) {

And Here Is my PHP File code:


$ccenter = $_POST['ccenter'];



Your data format is wrong ,must be {data-name:data-value}

data: {name: 'ccenter', value: 'Sales Department' } 

So you should call by data-name

$ccenter = $_POST['name'];