0
저는 AJAX를 처음 사용하면서 완전히 잃어 버렸습니다. 저는 4 개국 (미국, 캐나다, 멕시코, 러시아)이있는 곳에서 사용자가 라디오 버튼을 선택하면 4 개의 텍스트 파일 중 하나를 잡고 국가에있는 도시를 표시합니다. (그 도시들은 텍스트 파일 안에 있습니다.) 아무도 도와 줄 수 있습니까? Apperently 텍스트 파일은 다른 사이트에 있습니다.AJAX를 사용하여 텍스트 파일의 내용 표시
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- This is assign09.html -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> Ajax </title>
<script type="text/javascript">
function loadXMLDoc() {
req=new XMLHttpRequest();
req.onreadystatechange=function() {
if (req.readyState==4 && req.status==200) {
document.getElementById("div1").innerHTML=req.responseText;
}
} // end of onreadstatechange function
req.open("GET","usa.txt",true);
req.send();
}
</script>
</head>
<body>
<h1 style="text-align:center">Countries</h1>
<form name="submission" action="">
<input type="radio" name="countries" id="usa" value="1">USA</br>
<input type="radio" name="countries" id="canada" value="2">Canada</br>
<input type="radio" name="countries" id="mexico" value="3">Mexico</br>
<input type="radio" name="countries" id="russia" value="4">Russia</br>
<button class="buttonS" type="submit">Submit</button>
</form>
</body>
</html>
"usa.txt"는 어디에 있습니까? – briosheje
선생님의 사이트에서. 하지만 특정 국가를 선택할 때 다른 텍스트 파일 (예 : mexico.txt 등)을 가져올 수 있도록하고 싶습니다. 파일은 "http://157.201.194.254/~ercanbracks" –
에 있습니다. 가능한 경우 jQuery를 사용해야하며 함수를 가져옵니다. –