phpで処理した配列を、htmlファイルのjQueryの中で出力したいです。
php
1for($i=1; $i<=5; $i++){ 2$url = 'inc/load'. $i . '.inc'; 3$html = file_get_contents($url); 4$contents = ""; 5ob_start(); 6include($url); 7$contents[$i] = ob_get_contents(); 8$arr[$i] = $contents[$i]; 9 10ob_end_clean(); 11}
html
1<?php require_once('loadData2.php'); ?> 2<script type="text/javascript"> 3$(function(){ 4var maxLoad = 5; 5var s = 1; 6var $test = 0; 7<?php $s = 1; ?> 8 9 $(window).on("load scroll",function() { 10 var sampleH = $('#sample-text').height(); 11 var position = $(window).scrollTop() + $(window).height(); 12 13 if(document.getElementById("sample-result") != null){var flag = $('#sample-result').offset().top;} 14 15 /*** マックスまで読み込んだら、ロード画像を消す****/ 16 if(s == maxLoad){$('#sample-result').css({'display':'none'})} 17 <?php $s++; ?> 18 19 if((<?php echo $s; ?> < maxLoad)&&(flag <= position-100)){ 20 $('#sample-result').remove(); 21 <!--ここで実行してloadData2.phpの配列を出力したいです--> 22 $('section').append('<div id="sample-result"><p style="text-align: center; width: 100%"><img src="loadinfo.net.gif" alt="" width="100%"></p></div>'); 23 24 } 25 26 }); 27 28<body> 29<section> 30 <div id="sample-text"></div> 31 <div id="sample-result"><p style="text-align: center; width:100%;"><img src="loadinfo.net.gif" width="100%" alt=""></p></div> 32</section> 33</body> 34 35 36 37}); 38</script> 39 40
上記を別ファイルで読み込みphp内でechoする事はできたのですが
scriptの中で変数に入れてalertすると、script自体が止まってしまいます。
初歩的質問でもうしわけないのですが、よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー