简体   繁体   English

jQuery Ajax页面加载

[英]Jquery Ajax page loads

hi i have the following code, that has a problem. 嗨,我有以下代码,这是一个问题。

Every time i load the the script the first link loads in the div, however any other links wont load in the div. 每次我加载脚本时,第一个链接都会加载到div中,但是其他任何链接都不会加载到div中。

Do i need to reinitialise the script after the Ajax call. 在Ajax调用之后,是否需要重新初始化脚本。

I am not an expert in jquery, or ajax. 我不是jquery或ajax的专家。 What i am trying todo is load all links into a div. 我想做的是将所有链接加载到div中。

<div id="siteloader" style="width: 900px; height: 500px;">
</div>

<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>

<script>
jQuery(document).ready(function(){

jQuery('a').click(function(event){
   event.preventDefault();

   var href = jQuery(this).attr('href');
        $("#siteloader").load(href);
        success: initGenWidgets();
  });
});
</script>

<a href='http://tired.com/'>One</a>
<a href='http://www.bbc.co.uk'>two</a>

This code: 这段代码:

    $("#siteloader").load(href);
    success: initGenWidgets();

should be changed into this: 应更改为:

    $("#siteloader").load(href, initGenWidgets);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM