Vue.js Axios.post向php发送变量,但我无法访问这些变量

I'm new to frontend development, and I'm facing a problem that I cannot resolve.

What I am trying to do is open a new popup HTML page with parameters (which I can pass as an array) by calling method from my vue.js file.

I googled possible solutions, but still could not find the source of the problem. Observing Chrome console, I suspect that works fine since it says:

data: "Array( [index_id] => 1 [log_id] => 63)…ow.print(); // });", status: 200, statusText: "OK", headers: {…}, config: {…}, …}

However, in the popup window, I cannot access the variables, or they are null.

The following code is a function in my vue.js:

printTransaction: function(index){
    // I have tried this but could not figure out
    // var formData = new FormData();
    // formData.append('index_id', index);
    //'/popup/popup_output_print.php', {
    //     index_id: index,
    // })
    // .then(function(response){
    // })
    // .catch(function(error) {
    //   console.error(error);
    // })

    // and this too :(
    const params = {
        index_id: index,
        log_id: logId,
    };'/popup/popup_output_print.php', params, {
        headers: {
            'content-type': 'application/json',
    .then(function(response) {;
    .catch(function(error) {

    let newWin ='/popup/popup_output_print.php');
    setTimeout(function() {
    }, 2000);

And this is the very first part of popup_output_print.php

<?php require("../_/inc/init.php");
    $data = json_decode(file_get_contents("php://input"), TRUE);
    $index_id = $data['index_id'];
    $log_id = $data['log_id'];

//Trying to print the value

    if($index_id == null) {
        echo "index_id is null";
    else {
        echo $index_id;

Then the popup window prints index_id is null

What am I doing wrong?

UPDATE: following the comment, I just tried var_dump, and the variables are all null. :(

doujia7094 感谢您的评论。我刚尝试使用var_dump,看起来它们都是null:(
大约 2 年之前 回复
douye5949 您应该首先执行var_dump以确保正确接收发布的值。
大约 2 年之前 回复


What is going on is that have totally no effect to

let newWin ='/popup/popup_output_print.php');

this makes a GET request with no params.

From my view, the better approach is to use something like Vue modal, i.e.:

axios(...).then( response => openVueModal(

If you prefer option, you can pass variables as a GET params:

let newWin =`/popup/popup_output_print.php?index_id=${index}&log_id=${logId}`);

You'll need to change backend then, to read vars from $_GET.

Other solution might be to, put into window open template, so it request needed variables after opening.

dqthn68688 更新答案@BKHwang
大约 2 年之前 回复
dongpu1331 谢谢您的回答。 但我需要打开一个新窗口。 有没有其他方法可以打开带有参数的新窗口?
大约 2 年之前 回复
Csdn user default icon