mt0s
mt0s

Reputation: 5821

jQuery AJAX() method just want to send a value in a php file

i use this code :

$(document).ready(function() {

                        $.ajax({
                              url: 'server.php',
                              type: 'POST',
                              data : {temp : '100'},
                              success: function(data) {
                                alert('Load was performed.');
                            }   
                    });

    });

and just want to take the value of temp at the server.php file and print it , what im doing is $_POST['temp']; but dont have results

Upvotes: 1

Views: 77

Answers (2)

Alexander_F
Alexander_F

Reputation: 2877

Try this

$(document).ready(function() {

                    $.ajax({
                          url: 'server.php',
                          type: 'POST',
                          data : "temp=100",
                          success: function(data) {
                            alert('Load was performed.');
                        }   
                });

});

Upvotes: 0

Jacob Relkin
Jacob Relkin

Reputation: 163288

On the PHP end, you need to actually output that by passing it to echo:

echo $_POST['temp'];

Upvotes: 1

Related Questions