jquery - Nivo Slider dose not load the Ajax response from PHP file -
i'm trying import images html using php, nivoslider not loaded that. looked cause of problem. printing alert message of response , right.
here html , ajax query:
<div id="workcontent" class="pcontent" style="display:none;"> <div class="slider-wrapper theme-default"> <div id="slider" class="nivoslider"> </div> </div> <script> $(document).ready(function() { var wl = $('#worklist div'); wl.on('click', function(){ var name = $(this).attr('id'); console.log(name); $.ajax({ url: 'read.php', type: 'post', data: { data : name } }).done(function (response) { $('#slider').prepend(response); alert(response); }); }); }); </script> <div id="back"></div> <div id="backcontainer"> <div id="back"> <a href="index.php">back</a> </div> </div><!--end backcontainer--> </div><!--end content-->
and here other jquery:
<script> $(document).ready(function() { $('#slider').nivoslider(function(){alert('ok');}); }); </script>
this alert don't show! ):
finally, here php code:
<?php if (isset($_post["data"])){ if ($_post["data"] == "") { echo "data ures"; } else { $data = $_post["data"]; $fname = "content/".$data."/*.*"; $files = glob($fname); ($i=0; $i<count($files); $i++) { $num = $files[$i]; echo '<img src="'.$num.'" data-thumb="'.$num.'">'; } } } else { echo "nem jott data"; } ?>
sorry bad english
nivoslider doesn't take function argument.
also .nivoslider()
called before ajax call returns it's response. better solution be:
$(document).ready(function() { $.ajax({ url: 'read.php', type: 'post', data: { data : name } }).done(function (response) { $('#slider').prepend(response).nivoslider( {} ); }); });
now can sure #slider
contains images response body nivoslider can act on them.
Comments
Post a Comment