开发者

Fading in PHP post return data with jQuery

开发者 https://www.devze.com 2023-04-06 02:42 出处:网络
This is my current jQuery: $(\'#submit\').click(function() { var texts = $(\'#texts\').val(); var calls = $(\'#calls\').val();

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.


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

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


$(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();
});
});
});
0

精彩评论

暂无评论...
验证码 换一张
取 消