Load a page with html / js using AJAX

I am trying to load a php page using AJAX. The problem is that he has a “Share this” button, which uses a Javascript script that loads on the same page.

When I load a page using AJAX, the "Share this" button does not display correctly, because Javascript inside does not load.

Any ideas on how I can do Javascript on the download page?

Thanks Alain

PS I am using jQuery for javascript

UPDATE:

I still can't get it to work. Here is the html / js I'm trying to download:

<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style ">
<a href="http://www.addthis.com/bookmark.php?v=250&amp;username=leblon" class="addthis_button_compact" addthis:url="<?php the_permalink(); ?>" addthis:title="<?php the_title(); ?>">Share
<span class="at300bs at15t_compact"></span>
</a>
<span class="addthis_separator">|</span>
<a class="addthis_button_preferred_1"></a>
<a class="addthis_button_preferred_2"></a>
<a class="addthis_button_preferred_3"></a>
<a class="addthis_button_preferred_4"></a>
</div>


<script type="text/javascript">var addthis_config = {"data_track_clickback":true};</script>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=leblon" id="the-script"></script>
<!-- AddThis Button END -->

Here is a snippet of my javascript file:

$.ajax({ url: theURL + link+'/?from=us', success: function(html){
  $('#drink').html(html);
}

Is anyone

+3
source share
3 answers

EDIT / REDO:

AddThis, , , .

HTML

<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
<script type="text/javascript">stLight.options({publisher:'xxx-xxx-xx-xx-xx'});</script>

<span class="st_twitter_large" displayText="Tweet">
</span><span class="st_facebook_large" displayText="Facebook"></span>
<span class="st_ybuzz_large" displayText="Yahoo! Buzz"></span>
<span class="st_gbuzz_large" displayText="Google Buzz"></span>
<span class="st_email_large" displayText="Email"></span>
<span class="st_sharethis_large" displayText="ShareThis"></span>

AJAX SIDE ( )

<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>

<script tyle="text/javascript">
 var addthis_config = {"data_track_clickback":true};
$(document).ready(function(){
    $.ajax({ url:'test.php', success: function(html){
    $('#content').html(html);

}});
});
</script>
</head>
<body>
<div id="content" style="width:400px;border:1px solid black;height:300px;margin:auto"></div>
</body>
</html>

, init() ajax .

+1

, .

- :

$.get('/path/to/new/page', function(data){
    $('#someDiv').html(data);
});

, script . , , jQuery, : $('#someDiv')[0].innerHTML = data, , script, .

0

AJAX onComplete/success, js, .

$.ajax({
  url: "YourPage.php",
  context: document.body,
  success: function(){
    //Call Share Button function
  }
});

And note if your button has custom events to use the .live binding method instead of the usual event handlers. (.live handles dynamic content)

0
source

All Articles