0
在代碼中有兩種方法,第1種方法應該讀取來自同一個example.com域的文本,第2個函數應該讀取來自不同域的文本,即Google.com/example.txt 。請讓我知道誰來做這件事。我不確定我是否正確地構思了這個問題。請問我,如果你不明白我的問題。Ajax跨域問題
//Ajax Question
//The html file path is http://example.com/example.html
<html>
<head>
<script type="text/javascript">
function Click1()
{
var div=// read the text from http://example.com/example.txt
document.getElementById("div1").innerHTML = div;
}
function Click2()
{
var div=// read the text from http://google.com/example.txt
document.getElementById("div2").innerHTML = div;
}
</script>
<body>
<input type="Button" Value="Button 1"name="textbox" onClick="Click1();"/>
<div id="div1">
</div>
<input type="Button" Value="Button 2"name="textbox" onClick="Click2();"/>
<div id="div2">
</div>
謝謝達林,我會試試這個。 –