How can I send a jquery var to php?
ajax, jquery, php
Solution
Is it just me or you are not using the response at all?
$.ajax({
success: function(){
$('#info-user').fadeToggle('slow', 'linear');
}
});
Your anonymous `success` function is ignoring all responses. I suspect your `#info-user` should be an empty element and you are not getting a visual feedback.
An example could be:
$.ajax({
success: function(response){
$('#info-user').html(response).fadeToggle('slow', 'linear');
}
});
Other alternative could be using `.load()`.
Problem
When I try to send a var with jquery, ajax php doesn't receive it, and I don't know why. This is my script: ``` function showHiddenUserInfoPanel(id){ $(document).ready(function(){ $('#admin-resume').fadeToggle('slow', 'linear', function(){ $.ajax({ async: true, type: "POST", dataType: "html", contentType: "application/x-www-form-urlencoded", data: "userid="+id, // Also I tried with : data: {userid: id}, url: "user-profile.php", success: function(){ $('#info-user').fadeToggle('slow', 'linear'); alert(id); // I receive the correct id value } }); }); }); ``` And this is my user-profile.php: ``` <div id="activity_stats"> <h3>Viendo el perfil de <?php echo $_POST["userid"]; ?></h3> </div> ``` Can anybody can help me? Thanks :)