var ajax = {
init:function(){
var r = false;
try {
if(r=new XMLHttpRequest()) ajax.q = function(){return new XMLHttpRequest();}
}catch(e){}
},
getq:function(){
if(!ajax.q)ajax.init();
return ajax.q();
},
post:function(url, query, options)
{
var q = ajax.getq();
q.onreadystatechange = function()
{
if(q.readyState == 4)
{
if(q.status >= 200 && q.status < 300)
{
if(options.done)options.done(q.responseText);
}else{
if(options.fail)options.fail(q.responseText);
}
}
};
try{
q.open('post',url,true);
}catch(e){
return false;
}
q.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
q.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
q.send(query);
}
};
// Запрос для поиска
function search_init()
{
search_query = ge('search_query');
online = ge('online');
photo = ge('photo');
search_row = ge('search_row');
ge('search_begin').onclick = function()
{
ajax.post('al_search.php',search_query,{
done: function(r){ // Вставка результат запроса.
search_row.innerHTML = r || '';
},
fail: function(r){
}
}
);
}
}