求助,js嵌套文件里面再嵌套一个php文件 为什么无效html 文件
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript" type="text/javascript" src="plus/ajax/a.js"></script>
<title>无标题文档</title>
</head>
<body></body>
</html>a.js
document.write("<scri"+"pt type='text/javascript' src='b.php'></scr"+"ipt>"); b.php
<?
header("Content-Type: text/html; charset=UTF-8");
echo "alert('test');";
?>
jsphp
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript" type="text/javascript" src="plus/ajax/a.js"></script>
<title>无标题文档</title>
</head>
<body></body>
</html>a.js
document.write("<scri"+"pt type='text/javascript' src='b.php'></scr"+"ipt>"); b.php
<?
header("Content-Type: text/html; charset=UTF-8");
echo "alert('test');";
?>
jsphp
解决方案 »
- JQUERY fadeTo的渐显效果,鼠标多次移动会出现多次渐显
- activeX授权使用问题。
- 怎么样用js或者jquery实现动态表格中 对于自身位置的识别?
- 请高手帮忙思路实现.
- 如何生成运单号?
- 急招资深javascript程序员
- jS(非组件方式)修改注册表中打印方向为横向打印
- 问:在session超时的时候,如何关闭打开的所有程序页面。在javascript里如何实现?如window.opener.parent.close();
- 孟兄请进!
- 我需要个日历。当选择了日期以后,旁边的文本框自动显示出选择的日期
- jqGrid 添加、修改时怎么自定义验证和提示
- jquery操作checkbox问题!
LZ先检查一下路径问题,看看直接访问b.php是否能看到输出的js代码。
再有就是,b.php中,Content-Type的报头不能是text/html,改成text/javascript或者application/javascript,或许就好了。
再<? print_r(""<script></script>); ?>如果是前端 判断的话 就用<scrip type="text/javascript" src="xxx"></script> 引入吧
路径没有问题 我改成 application/javascript 或者text/javascript 都不行,
你的a.js和b.php是都在ajax目录中吧
document.write()是向html文件中输出,所以src的路径要写成相对于html文件的路径
document.write("<scri"+"pt type='text/javascript' src='plus/ajax/b.php'></scr"+"ipt>");