[Javascript] - Ajax로 페이지 Call하는법
<script>
function Callajax(url){
try{
if(window.XMLHttpRequest){
tXhttp = new XMLHttpRequest();
} else if(window.ActiveXObject) {
try {
tXhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e1) {
try {
tXhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
}
}
}
}catch(e3){
try {
tXhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e1) {
try {
tXhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
}
}
}
if (tXhttp != null){
tXhttp.open("GET", url, false);
tXhttp.send();
if (tXhttp.readyState == 4) {
menuText = tXhttp.responseText;
}
}
return menuText;
}
function moviestart(lnk){
if (lnk == ""){
var url = "./movie_form.php";
}else{
var url = lnk;
}
var rtn = Callajax(url);
document.getElementById("movielist").innerHTML = rtn;
}
window.onload = function(){
moviestart("");
}
</script>