-1

コードの使用に問題があります:

<input id="button"  type="button" value="Load"/>
<div id="content"> </div>

<script src="js/ajax.js" type="text/javascript"></script>

ajax の使用: 実行されないようです。

$('#button').click(function() { 
    $.ajax({ 
        url: 'page.html', 
        success: function(data) {
            $('#content').html(data);
        }
    });
});

ページの html が含まれています<span>Hello</span>

誰でも私を助けることができますか?私はこれでテストし、適切に動作します:

<input type="text" onclick="$(this).hide();"/>

私が持っていることに注意してください<script src="js/jquery.js" type="text/javascript"></script>

4

3 に答える 3

2

jquery.js ライブラリをリンクしましたか?

于 2012-12-23T06:26:22.167 に答える
1

最初にページの上部にjqueryライブラリをロードします

于 2012-12-23T06:28:23.710 に答える
1

dataType を指定してみてください:

以下のコードを使用してください

<script>
$(function($) {
    $('#button').click(function() { 
        $.get('page.html',function(data)
        {
            $("#content").html(data);
        },"html")
    });
});
</script>

楽しんで:)

于 2012-12-23T07:22:12.803 に答える