php同时发布和重定向页面


php post and redirect page same time

我不是php专家,但我被困在这里了。我有以下三个.php文件

  1. index.php<-下拉列表,其中选择DB表。

  2. query.php<-它制作json查询。

  3. chart.hp<-这是图表JQuery页面。使用CCD_ 2函数从CCD_。

index.php将从选择DB/Table的下拉列表中获得用户输入,并将其传递给query.php并设置SELECT * FROM $table变量。

但我想做POST,同时它会打开chart.php页面,这样我就可以直接重定向到图表页面。我如何同时发送POST和Redirect,以便query.php获得$table变量并立即打开chart.php图表。

编辑:

如果我把所有的query.php代码都放在chart.php中,那么我如何把那些json值放在$.getJSON()中呢?

$.getJSON("query.php", function(json) {
                options.xAxis.categories = json[0]['data'];
                options.series[0] = json[1];
                options.series[1] = json[2];
                options.series[2] = json[3];
                chart = new Highcharts.Chart(options);
            });

$.getJSON()将如何从变量中获取值?

1)从index.php->使用所需参数向chart.php发出POST请求

2) 在chart.php上使用$_POST=>从index.php接收数据并在模板上显示,如:

用于查询的GET请求。php

$.getJSON("query.php?<?='param1='.$_POST['param1']?>", function(json) {
                options.xAxis.categories = json[0]['data'];
                options.series[0] = json[1];
                options.series[1] = json[2];
                options.series[2] = json[3];
                chart = new Highcharts.Chart(options);
            });

或者使用通常的$.ajax请求通过POST请求发送:

$.ajax({ 
         url: 'query.php',
         data: "<?='param1='.$_POST['param1']?>"
         dataType : "json",
         method:"POST",
         success: function(json){
                options.xAxis.categories = json[0]['data'];
                options.series[0] = json[1];
                options.series[1] = json[2];
                options.series[2] = json[3];
                chart = new Highcharts.Chart(options);
});

更新

如果您的服务器没有short_open_tag=打开-请使用<?php echo 'param1='.$_POST['param1'] ?>

在模板上给出参数之前检查参数