Home

Tags

jquery подгрузка данных

2010-04-29 jquery ajax

Пример подгрузки данных на jquery

<html>
<head>
    <script type="text/javascript"
        src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" language="javascript">
      $(document).ready(function(){
        $("#up1").bind("click", function(e){
            $.get("./file.html", function(data) {
                $("#msg").append( data );
             });
        });
        $("#up1").bind("mouseenter mouseleave", function(e){
            $(this).toggleClass("over");
        });
      });
    </script>
    <style>
      #up1 { background:yellow; font-weight:bold;
        cursor:pointer; padding:5px; }
      #up1.over { background: #cfc; }
    </style>
</head>
<body>
  <span id=up1>Get data</span><br />
  <span id=msg />
</body>
</html>
и рядом нужно положить файл file.html с содержимым которое нужно отображать