0

示例代码:

<html>
    <head>
        .....
    </head>
    <body>
        <div id="content">
            <form>
                ....
                <input type="submit" onclick="loadAnotherPage()"/>
            </form>
        </div>
    </body>
</html>  

我想在div 中加载另一个页面,比如edit_profile.phpcontent。不刷新页面怎么实现?

我尝试使用 jQueryload()方法。但看起来我错过了什么。任何帮助将不胜感激。

4

3 回答 3

3

当您单击submit button它的提交表单和页面刷新时,这就是它不起作用的原因。

而不是输入提交设置按钮,然后设置功能onclick

function loadAnotherPage(){
    $("#content").load('edit_profile.php');
}
于 2013-03-21T10:58:41.660 回答
0

尝试这个

<html>
 <head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
 </head>
    <body>
     <div id="content"></div>
      <button id="loadpage">load new page</button>
<script>
 $(document).ready(function () {
    $("#loadpage").click(function() {
        $.get("edit_profile.php", function(response){
          $("#content").html(response);
        });
    })
 });
</script>
    </body>
</html> 
于 2013-03-21T11:18:55.123 回答
0
           $(document).ready(
            function() {
              $('#load_file').click(
            $.post('edit_profile.php',
             {},
             function(data){
                $("#content").html(data);
             },''
            )
               ); 
                }
                    );
于 2013-03-21T11:01:27.633 回答