Get value - ajax

hi

normally when we send a value, it looks like this:

data="something"

In the other php file:

$form = $_POST['data'];

But suppose, that i sent only the content

something

in the other php file, the same aproach didn’t work

$form = $_POST[???]

How can i get the value that is send, in my case-- just, the word something ?


$.ajax({
                            url: "get.php",
                            type: "post",
                            dataType: "json",
                            data:'<?php echo $data; ?>',	 	  
                            success: function() {
                            	$('#total').load('xxx.php');
                                }
                        });

Do a print_r($_POST); and see what it contains

i am sending:

something

but the

 print_r($_POST);

show

Array
(
)

What does $data contain in <?php echo $data; ?> that you use in your ajax?

The data param of $.ajax needs an object, like {param1: ‘value1’, param2: ‘value2’}

BTW. Posting data to get.php is a very good way to confuse yourself (as there also is an HTTP method GET) – please rethink that for your own sake :slight_smile:

hi

this solve my problem

 data:"postedvariable=<?php echo $something; ?>",       	

thanks