2011-09-19 61 views
0

後返回數據這是我目前的jQuery:衰落在PHP中使用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); 
}); 
}); 

這是HTML的div:

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

我將如何獲取從返回的數據PHP文件,而不是隻顯示它,讓它淡入jQuery。對不起,如果這是一個愚蠢的問題,我有點在jQuery noob。

回答

3

這是一個。它隱藏#result格設置第一,以響應數據填充它和

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

+1短,甜,非常的jQuery消失 – Endophage

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