$("#search-box").keyup(function(){
var filter = $(this).val();
var req = {
action: 'getItem',
filter: filter
};
this.getJSON('videos.php', req, function(serverData)
{
});
});
我有上面的函数返回值。如何返回 serverData ?
答案 0 :(得分:-1)
尝试类似:
$("#search-box").keyup(function(){
var filter = $(this).val();
var that = this;
var req = {
action: 'getItem',
filter: filter
};
$.when( $.getJSON( "videos.php", req ) ).then(function( serverData, textStatus,jqXHR )
{
call_some_function_which_handles_response(serverData);
});
});