2011-11-08 14 views
0

私の部門に外部のjQueryプレーヤーをロードしたい#player。変更を見つけるためにいくつかのアドレスを試しましたが、コンテンツは含まれていません。私は間違って何をしていますか?jQueryロード機能は何もしません

// This one is okay 
    $("li a").live("click", function(){ 
      $("#textoPequeno").load($(this).attr('href'));  
      return false; 
    }); 

    //This one is not doing anything 
    $(document).live(function() { 
    $("#player").load("http://code.internuts.se/jquery/iwish/index.html"); 
    }); 

HTMLのCODE:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"><head> 
<link href="css/style.css" media="screen" rel="stylesheet" type="text/css"> 
<link rel="stylesheet" href="css/simpleplayer.css" type="text/css"> 
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.min.js"></script> 
<script type="text/javascript" src="include/javascript.js"></script> 



<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<title>Opera</title> 
</head> 

<body> 
    <div id="main"> 
     <div id="header"> 

      <h1 id="logo"> 
       <a href="#">Linux Logo</a> 
      </h1> 

      <ul> 
       <li><a href="1.html">Home</a></li> 
       <li><a href="2.html">Navegación</a></li> 
       <li><a href="3.html">Novedades</a></li> 
       <li><a href="4.html">Diseño</a></li> 
       <li><a href="5.html">Multimedia</a></li> 
      </ul> 

      <div id="player"> 
      </div> 

     </div> 
    <div id="imagen"></div> 
    <h2 id="textoGrande"><p>Opera ahora<br /> mas acojedor...</p> 
    </h2><h3 id="textoPequeno"><p>La hegemonía de Internet Explorer, el navegador web de Microsoft, poco a poco va llegando a su fin. Durante los últimos años hemos asistido a la aparición de nuevos navegadores que han explotado las carencias de Internet Explorer, incorporando nuevas características ausentes en éste.</p> 

    </h3></div> 


</body></html> 
+0

$(document).ready(function(){ // Your code he再 });どこでも – MRR0GERS

答えて

2

それも、この変更を行った後、私はまだあなたが私はこれがあなたのドメインではありません推測している、クロスドメインAJAXリクエストを制限same origin制限に実行されます疑うdocument.ready

$(document).ready(function() { 
    $("#player").load("http://code.internuts.se/jquery/iwish/index.html"); 

    // include this in the document.ready as well because in order to attache the events the document needs to be ready. 
    $("li a").live("click", function(){ 
      $("#textoPequeno").load($(this).attr('href'));  
      return false; 
    }); 
}); 

する必要があります。

0

私はあなたの呼び出しは、あなたがそれだと思う何をやっているとは思いません。

$(function() { 
    $("#player").load("http://code.internuts.se/jquery/iwish/index.html"); 
}); 

$(....)がdocument.readyのためのjQueryの省略形です...代わりにこれを試してみてください。 jQueryにパラメータとして渡された関数は、document.readyにバインドされます。

0
あなたが jQuery.live()悪用されている

は、DOM要素のイベントハンドラをバインドするための機能が変更または置換されている - 私はあなたがここに欲しいことはjQuery.ready()だと思う:これもでき

$(document).ready(function() { 
    $("#player").load("http://code.internuts.se/jquery/iwish/index.html"); 
}); 

次のように簡略化されました:

$(function() { 
    $("#player").load(...); 
}); 
関連する問題