My Blog List

Monday, October 22, 2012

Ajax Example MyStyle


function sendAjax() {

var xhr = new XMLHttpRequest();

var params="company_id="+"203"+"&"+"search.max="+max+"&"+"search.pos="+pos;
xhr.open( "GET",
'url?' + params,
true);
xhr.setRequestHeader(
'app-agent',
'platform_kind=20;platform_ver=1.0.1;device_id=0a171eecebeb462b1ba40f02c2d0d4374889d268;app_name=eagletalk_mobile;app_vers=3.0.4;device_model=jmeter;emulator=true;network_type=WiFi;');
xhr.setRequestHeader('access-token',
'gw343#Gb8MGMbNeHsHj22p4uuRD85cdQM=');
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200)
{
var obj = eval( '(' + xhr.responseText + ')' );
var list =  obj.list;
for(var i=0; i<list.length; i++){
var html= '<div class="frame" id="frame">'+
'<div id ="content" class="ccc">'+
'<p id="content_title"><strong>'+list[i].title+'</strong></p>'+
'<p id="right_time"><strong>'+getDate(list[i].reg_dttm)+'</strong>PM</p>'+
'</div>'+
'<div id="right_navi">'+
'<div id ="icon">'+
'<img src="image/com_icon_arrow.png">'+
'</div>'+
'</div>'+
'</div>'
$("#scroller-body").append(html);
}

// refresh
if(myScroll != null){
myScroll.refresh();
}
listSetting();
pos = pos+max;
isWorking = false;
}


}
xhr.send();
}

No comments:

Post a Comment