I would like to preform exterlan API call from PHP code and open a result in new browser tab.
My approach:
There is a form with button. In JS I handle OnClick and call nuRunPHP('MyProcedure');
In that procedure I prepare some server-side dara and do:
Code: Select all
// Prepare POST data
$options = [
'http' => [
'method' => 'POST',
'header' => 'Content-Type: application/json',
'content' => json_encode($data),
],
];
// Create stream context
$context = stream_context_create($options);
// Perform POST request
$response = file_get_contents($url, false, $context);
// Display the response
header("Content-Type: application/pdf");
echo $response;
If you delete 2 lines after
Code: Select all
//Display the response
What is the reason of 2 times calling?
Thank you