note : please dont use "\" in script cause error while write the blog.
Ajax Open page without loading (whatever lah for the subject just see the script)
this code is for get data from server without refreshing or move to other page.
this script is basic for every ajax web application.
---Start script---
<\script type='text/javascript'>function createRequestObject() {
var ro;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
ro = new ActiveXObject("Microsoft.XMLHTTP");
}else{
ro = new XMLHttpRequest();
}
return ro;
}
var xmlhttp = createRequestObject();
function setData(frm,combobox)
{
alert(combobox.value);
return false;
var kode = combobox.value;
var form = frm;
if (!kode) return;
xmlhttp.open('get', form+'.jsp?critID='+kode, true);
xmlhttp.onreadystatechange = function() {
if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200))
document.getElementById("dataMetric").innerHTML = xmlhttp.responseText;
return false;
}
xmlhttp.send(null);
}
<\/script>
---EndScript---
how to use?
<\div id="dataMetric"><\/div>
<\script language="javascript1.2">setData("frm","1");<\/script>
<\div id="dataMetric"><\/div>
<\script language="javascript1.2">setData("frm","1");<\/script>
No comments:
Post a Comment