Shane
Shane

Reputation: 23

Fading in PHP post return data with jQuery

This is my current jQuery:

$('#submit').click(function() { 
    var texts = $('#texts').val();
    var calls = $('#calls').val();
    var callstometeor = $('#callstometeor').val();
    $.post('compare.php', { texts: texts, calls: calls, callstometeor: callstometeor }, function(data) {
    $('#result').html(data);
} );
} );

And this is the HTML div:

<p><div id="result"></div></p>

How would I get the data that is returned back from the PHP file but instead of just displaying it, make it fade in with jQuery. Sorry if it's a stupid question, I'm a bit of a noob at jQuery.

Upvotes: 0

Views: 794

Answers (2)

Muhammad Usman
Muhammad Usman

Reputation: 12503

$(function(){
$('#submit').click(function() { 
    var texts = $('#texts').val();
    var calls = $('#calls').val();
    var callstometeor = $('#callstometeor').val();
    $.post('compare.php', { texts: texts, calls: calls, callstometeor: callstometeor }, function(data) {
    var res= data; //here you get the response
    alert(res);
    $('#result').hide().html(data).fadeIn();
});
});
});

Upvotes: 0

genesis
genesis

Reputation: 50974

This one does it. It hides #result div first, fills it with response data and fades in

$('#result').hide().html(data).fadeIn();

Upvotes: 3

Related Questions