Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resource interpreted as Document but transferred with MIME type application/x-javascript

Tags:

html

php

I have a simple php file having only:

<?php

header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("content-type:application/javascript");
echo "var md = 0 ";

In my html file I am calling the php file in iframe:

<iframe src="../API/index.php?i=MTQ4MDkyMDY1Mg==&d" width="100" height="100"></iframe>

While using the link in script tag its working but when I try to use it in iframe I'm getting the mime application/javascript error.

like image 605
Tina Avatar asked Jun 05 '26 19:06

Tina


1 Answers

An Iframe can only accept html document.

You can do the js inside your html.

<iframe src="../API/index.php?i=MTQ4MDkyMDY1Mg==&d"></iframe>

and inside the php, remove all headers and do...

echo "<script type='text/javascript'>var md = 0; </script>";
like image 152
Syed Waqas Bukhary Avatar answered Jun 07 '26 07:06

Syed Waqas Bukhary



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!