Loading failed for the <script> with source when mix with PHP

时间:2019-04-16 22:11:06

标签: javascript php google-chrome firefox

I have javascript script which I am generating using php. Lets call it js.php , when I put raw text inside and try to link it from other page it works fine. Moment I add php code into script I get

Loading failed for the < script > with source

js.php

< ?php 

header('Access-Control-Allow-Origin: *');
header('Content-Type: application/javascript');

? >

console.log('javascript is loaded');

If I remove the php code from the top file loads fine, moment add it back it gives me error, I have check in firefox and chrome the same issue

0 个答案:

没有答案