【发布时间】:2009-12-29 20:54:43
【问题描述】:
在代码中有两种方法,第一种方法应该从同一个域中读取文本,即 example.com,第二种方法应该从不同域中读取文本,即 Google.com/example.txt。任何人都可以让我知道谁来做这件事。我不确定我是否正确地提出了这个问题。如果你不明白我的问题,请问我。
//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>
【问题讨论】:
标签: ajax cross-domain