嗨,我有一個問題在這裏 這是我的代碼,它的工作時,我寫「http:// localhost」和檢索內容,但是當我寫其他網站,如「http ://www.google.com「它不起作用。 我已經在我的虛擬主機中上傳了代碼給你們測試它。 這是鏈接。 http://faceproishere.netii.net/test.php 在這裏你可以看到我的代碼:jquery得到我的本地主機,但不是其他網站的作品
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>
</head>
<body>
<input type="text" name="field1" id="field1" value="http://localhost">
<input value="load" type="button" onClick="my_function()">
<textarea cols="15" rows="12" id="frame1" style="float:left"></textarea>
<div id="frame2" style="width:400px;height:400px;overflow:scroll;fl oat:left"></div>
<script type="text/javascript">
function my_function()
{
if($("#field1").val() != '' && $("#field1").val().indexOf("http",0) == 0)
{
$.get($("#field1").val(),function(data)
{
$("#frame1").html(data)
$("#frame2").html(data)
})
}
}
</script>
</body>
</html>
TNX提前。
是jQuery的託管在谷歌的CDN不應該是」'的https:// ajax.googleapis.com/AJAX /庫/ jQuery的/ 1.7.2/jquery.min.js' – Undefined