skip to Main Content

I sent an array to the server using AJAX:

$(document).on("click", "#create_qr_codes_pdf", function(ev) {
        ev.preventDefault();
        var qr_array = [];

        for (var i = 0; i < $("#qrcode_top img").length; i++) {
            qr_array.push($('#code' +i+' img').attr('src'));
        }
        $.ajax({            
            url: 'server/qr_id_create.php?create_qr_codes_pdf',
            type: 'POST',
            data: {qr_array: qr_array},
            success: function(data) { 
                console.log(data);
                window.open("server/qr_id_create.php?create_qr_codes_pdf");
            }
        });
    });

In PHP I am receiving the array like this:

if (isset($_GET['create_qr_codes_pdf'])) {
        $qr_images = $_POST['qr_array'];

        require_once('tcpdf/tcpdf.php');
        require_once('tcpdf/config/tcpdf_config.php'); 
        $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
        $pdf->SetCreator(PDF_CREATOR);
        $pdf->SetAuthor('Nicola Asuni');
        $pdf->SetTitle('TCPDF Example 009');
        $pdf->SetSubject('TCPDF Tutorial');
        $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
        $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 009', PDF_HEADER_STRING);
        $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
        $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
        $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
        $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
        $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
        $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
        $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
        $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
        if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
            require_once(dirname(__FILE__).'/lang/eng.php');
            $pdf->setLanguageArray($l);
        }

        $pdf->AddPage();

        foreach ($qr_images as $img) {
            $img = preg_replace('/^[^,]*,s*/', '', $img);
            $img = base64_decode($img);
            $pdf->Image('@'.$img);
            $pdf->AddPage();
        }

        $pdf->Output('qr_codes.pdf', 'I');
}

Here is how I test the array in php:

if (isset($_GET['create_qr_codes_pdf'])) {
    $qr_images = $_POST['qr_array'];
    if (is_array($qr_images)) {
        echo 'true';
    } else {
        echo 'false';
    }
    var_dump($_POST);
}

However, I keep getting an Undefined index error with the qr_array in php on line (in this case) 2.
When I check if the array is an actual array it returns ‘false’.

var_dump($qr_images);

Returns the following result:

array(1) {
  ["qr_array"]=>
  array(2) {
    [0]=>
    string(4658) "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAANXElEQVR4Xu3dS1Il2w4D0MP8B80LotrkItDV2xtQdV22ZVlKJ/+31+v1/vrF/97fn8d7e3t7nF75ok71la94G5/qt+fT/O34hzpmkAeWJRAtqC2gNj7Vb88nftvxGWQXJLqgM0jbouX66RNQ+YLfFlAbn+q35xO/7fguyC7ILsgDAzPIDDKDzCCfM6BXBL1i6MSrvvIVb+NT/fZ8mr8d3wXZBdkFSS6IniBtB6u+nmApftUXvnb/tL7wKy5+TuNL8fOC/PQBU/wSgBbQ7p/WF37Fxc9pfCn+GQQMSgBaQCoQ9U/rC7/it+NL8c8gM4g09BifQfC9TBG7/0Fye0GqrxHSJ7z6p/WFX/Hb8aX4d0F2QaShXZAnBk4/obS99hNM9YUv5U/90/rCr/jt+FL8uyC7INLQLkhyQfQEidj/+F78wz/PIfyaP8Wv/rfXb+Nr8xNfEAlEAyieEqx89Vdc86u/8tX/9vptfG1+ZhAxHL6CtQVye/02Pq0v7T+DiOEZpPoxSHpBtb4ZpPzNhlqAFpwuSP1vr9/G1+ZnF0QM74LsguyzWN93yS5I9lthxN/3N/MvM71guyDhBrTgdEGCd3v9Nr42PzOIGC7HZbC0vQSa1hd+9Vd+ii/tP4O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C38WeQGWQGOSjwH9QE2EOHzmA5AAAAAElFTkSuQmCC"
  }
}

However, if I get the output in a new window as specified in Jquery on AJAX success: window.open("server/qr_id_create.php?create_qr_codes_pdf"); I get a var_dump($qr_images) result array(0) { }

Can anyone please identify the issue here? I am pulling out my hair!

2

Answers


  1. i think the best way you send JSON format, not in array

    Login or Signup to reply.
  2. First time you have POST data:

    $.ajax({            
        url: 'server/qr_id_create.php?create_qr_codes_pdf', <--HERE YOU HAVE POST DATA
        type: 'POST',
        data: {qr_array: qr_array},
        success: function(data) { 
            window.open("server/qr_id_create.php?create_qr_codes_pdf");  <--HERE YOU DON'T HAVE POST DATA
        }
    });
    

    So, you need to check when is a POST request with:

    if(isset($_POST['qr_array'])) {
        //the code for ajax request
        $qr_images = $_POST['qr_array'];
        if (is_array($qr_images)) {
            echo 'true';
        } else {
            echo 'false';
        }
    } else {
        //the code you expect to run after the request is successfull
        echo 'request success';
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search