I'm trying to load a content into a div with this:
$(document).ready(function(){
$(".produkty").click(function(){
var post_id = $(this).attr("href");
$("#single_product_box").load(post_id + " #main" );
return false;
});
});
The other scripts I use are here:
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="<?php echo get_template_directory_uri(); ?>/js/jcarousellite_1.0.1.min.js" type="text/javascript"></script>
<script>
$(function() {
$(".anyClass").jCarouselLite({
btnNext: ".next-any",
btnPrev: ".prev-any"
});
});
$(function() {
$(".anyClass-2").jCarouselLite({
btnNext: ".next-any2",
btnPrev: ".prev-any2"
});
});
Everything is fine, but after first load it stopped working. I've tried to use something like this:
$.ajax({
url: '$post_id',
cache: false,
beforeSend: function (data) {
$('#single_product_box').html("Loading...");
},
success: function (data) {
if (data!='error'){
$('#single_product_box').html(data);
}else{
$('#single_product_box').html("<span style='color:red;'>Error!</span>");
}
},
error: function (data) {
$('#single_product_box').html("<span class='error'>Error!</span>");
}
});
but I cannot make it work again, I even tried to put the scripts into loaded content, but it disappears as well. I just had no more ideas.