Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/419.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP进度条可以与$\u会话一起使用吗?_Php_Javascript_Jquery_Jquery Ui_Progress Bar - Fatal编程技术网

PHP进度条可以与$\u会话一起使用吗?

PHP进度条可以与$\u会话一起使用吗?,php,javascript,jquery,jquery-ui,progress-bar,Php,Javascript,Jquery,Jquery Ui,Progress Bar,我们希望将Jquery进度条与PHP集成。我们已经实现了$\u会话,但是根据我们的要求,我们没有得到确切的值 请看我们的代码 HTML <!DOCTYPE html> <html> <head> <title>Jump for Joy</title> <link href="styles/my_style.css" rel="stylesheet"> <link href="http://a

我们希望将Jquery进度条与PHP集成。我们已经实现了$\u会话,但是根据我们的要求,我们没有得到确切的值

请看我们的代码

HTML

<!DOCTYPE html>
<html>
<head> 
    <title>Jump for Joy</title> 
    <link href="styles/my_style.css" rel="stylesheet">
    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<style type="text/css">



 #bardivs {
   width:400px;
  position:relative;
  }
 #progresstext {
position:absolute;
top:0;
left:0;
}
 </style>
   <script>
   $(document).ready(function() {
       $("#sub").click( function() {
$.ajax({ 
  type : 'POST',
  url : 'http://localhost/tools/ip/html/demo.php',
  dataType : 'html',
  data: {
      camp_url : $('#camp_url').val(),
      captcha :  $('#captcha').val()
  },
  success : function(data){
  $('#message').removeClass().addClass(data).html(data).show(500);
  $("#progressbar").delay(100).hide(200);}


});
  var url = "http://localhost/tools/ip/html/xyz.php";
$(function() {
    $("#progressbar").progressbar({ value: 0 });
    setTimeout(function(){ updateProgress(0); }, 1000);
});

function updateProgress(data) {
    $.get(url+'?progress='+data, function(data) {
        // data contains whatever that page returns     
        if (data < 100) {
            $("#progressbar").progressbar({value: parseInt(data)});
            setTimeout(function(){ updateProgress(data); }, 1000);
    } else {
        $("#progressbar").progressbar({value: 100});
        $("#progressbar").delay(100).hide(200);
        }


  }); 
}
   });
 });
 </script>
    </head> 
    <body>
    <div id="header">
            <h2>Jump for Joy Sale</h2>
        </div>
           <div id="main">
            <div id="bardivs">
    <div id="progressbar"></div> 
    <div id="progresstext"></div>
    </div>
           <div id="message"  style="display: none;">
</div>
 <input type="submit" name="check" id="sub" value="submit">
    </div>
</body>
 </html>

高兴得跳起来
#巴蒂夫{
宽度:400px;
位置:相对位置;
}
#进度文本{
位置:绝对位置;
排名:0;
左:0;
}
$(文档).ready(函数(){
$(“#子”)。单击(函数(){
$.ajax({
键入:“POST”,
网址:'http://localhost/tools/ip/html/demo.php',
数据类型:“html”,
数据:{
camp_url:$('#camp_url').val(),
验证码:$('验证码').val()
},
成功:功能(数据){
$('#message').removeClass().addClass(data.html(data.show)(500);
$(“#progressbar”).delay(100).hide(200);}
});
变量url=”http://localhost/tools/ip/html/xyz.php";
$(函数(){
$(“#progressbar”).progressbar({value:0});
setTimeout(函数(){updateProgress(0);},1000);
});
函数updateProgress(数据){
$.get(url+'?进度='+数据,函数(数据){
//数据包含该页返回的任何内容
如果(数据<100){
$(“#progressbar”).progressbar({value:parseInt(data)});
setTimeout(函数(){updateProgress(data);},1000);
}否则{
$(“#progressbar”).progressbar({value:100});
$(“#progressbar”).delay(100).hide(200);
}
}); 
}
});
});
跳楼大甩卖
demo.php

<?php
session_start();
$set = $_SESSION['size'] ;
$array = array(100,200,300,400,500,600,700,800,900,1000);
$ab = 1 ;
@$size=sizeof($array);
$size = round(100/$size);
foreach($array as $a){
    echo $a ;
    sleep(1);
$_SESSION['size'] = $set + $size ;  
}
?>
<?php
session_start();
if(@$_SESSION['size'] <=100) {
    header("Refresh: 1; url=xyz.php");
}
@$_SESSION['size'];
   $set = (int)@$_GET['progress'] + @$_SESSION['size'];
   echo (int)$set ;
?>

xyz.php

<?php
session_start();
$set = $_SESSION['size'] ;
$array = array(100,200,300,400,500,600,700,800,900,1000);
$ab = 1 ;
@$size=sizeof($array);
$size = round(100/$size);
foreach($array as $a){
    echo $a ;
    sleep(1);
$_SESSION['size'] = $set + $size ;  
}
?>
<?php
session_start();
if(@$_SESSION['size'] <=100) {
    header("Refresh: 1; url=xyz.php");
}
@$_SESSION['size'];
   $set = (int)@$_GET['progress'] + @$_SESSION['size'];
   echo (int)$set ;
?>

我们在进度条过程之后获取数据,但没有获取进度条

谢谢


PPS

这正是您正在使用的代码吗?如果是这样,将
sleep(1)
切换为
sleep(1000)
很可能是demo.php在指示器发出请求时已经实际完成了。

可以实现ob_start()、ob_flush()、flush()?请在提问时花点力气,我需要阅读所有代码吗??。。请具体说明我们需要的问题是什么,一个用PHP构建的程序进度条。上面我们应用了一个jquery函数从PHP获取值。但我们无法先启动进度条,然后从demo.php获取其余数据,