Ajax - response равна undefined
Здравствуйте. Второй день изучаю...
$("#QuestForm").bind("keyup", show);
function show(){
response_ajax($.ajax({url:'/new.html',type:'GET',dataType:'html'}).responseText);
}
function response_ajax(response){
$("#QuickSearch").html("hello "+response);
}
В результате выводит hello undefined |
по моему лучше бы сделать так:
$.ajax({
url: '/new.html',
dataType:'html',
type: 'GET',
success: function(response) {
$("#QuickSearch").html("hello "+response);
}
});
По крайне мере должно работать :) |
ну да ток вот весь код...
$("#QuestForm").bind("keyup", show);
function show(){
$.ajax({url: '/new.html',dataType:'html',type: 'GET',
success: function(response) {
$("#QuickSearch").html("<ul><li>ubuntu</li><li>java</li><li>linux</li></ul>");
}});
$("#QuickSearch").show();
hover();
}
$("#QuestForm").bind("blur", hide);
function hide(){
$("#QuickSearch").hide();
}
function hover(){
$("ul li").hover(function(){
$(this).css("background-color", "#D5E2FF");
$("#QuestForm").val($(this).text());
},
function(){
$(this).css("background-color", "white");
});
}
Проблема в том что hover() не будет в таком случае работать... |
$(document).ready(function() {
$("#QuestForm").bind("keyup", show);
$("#QuestForm").bind("blur", hide);
});
function show(){
$.ajax({
url: '/new.html',
dataType:'html',
type: 'GET',
success: function(response) {
$("#QuickSearch").html("<ul><li>ubuntu</li><li>java</li><li>linux</li></ul>");
*!*$("#QuickSearch").show();*/!*
*!*hover();*/!*
}
});
}
function hide(){
$("#QuickSearch").hide();
}
function hover(){
$("ul li").hover(function(){
$(this).css("background-color", "#D5E2FF");
$("#QuestForm").val($(this).text());
},
function(){
$(this).css("background-color", "white");
}
);
}
Строчки $("#QuickSearch").show(); hover(); нужно было вложить в success |
Ок.. Большое спасибо))
|
| Часовой пояс GMT +3, время: 22:52. |