A PHP page, you need to pass some parameters to an external page, such as% , until then OK, but this external page has some JavaScript commands.
When I send via POST
or cURL
, the page loads, but JavaScript does not run.
I tried via Ajax , but it did not work because of the MVC structure of my Project.
Does anyone have any tips on how to call an external page via FileGetContent
and have this page run the inline JavaScript ?
As I'm calling via FileGetContent
$url = "http://localhost/workspace/application/files/origin/oitprintteste.php";
$content = http_build_query($data);
$context = stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => 'Content-Type: application/x-www-form-urlencoded',
'content' => $content,
)
));
$teste = file_get_contents($url,true,$context);
Now an example of how I call via cURL
$url = "http://localhost/workspace/application/files/origin/oitprintteste.php";
$content = http_build_query($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$teste = curl_exec($ch);