如果html中带有 “>>”,则“>>”以及后面的所有代码被清空,请问为什么,怎样解决?例子如下:
localhost下有以下2个文件:
test.html:<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>test page</title>
<script type="text/javascript" src="http://localhost/leb/auto/js/jquery-latest.js"></script>
<script type="text/javascript">
$(function(){
var html= $(".page")[0].innerHTML;
$.ajax({
cache : false,
type : "POST",
url : "file.php",
data : "html="+html,
dateType : "text"
});
});
</script>
</head>
<body>
<div class="page">
<span>more>></span>
<div>other infos</div>
</div>
</body>
</html>
file.php 文件:<?php
$html=$_POST['html'];
$file=fopen('result.html','w');
fwrite($file,$html);
fclose(file);
?>
打开test.html,jquery的ajax通过file.php生成的result.html中的代码只有<span>more后面的全没了,为什么会这样?怎么解决?
localhost下有以下2个文件:
test.html:<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>test page</title>
<script type="text/javascript" src="http://localhost/leb/auto/js/jquery-latest.js"></script>
<script type="text/javascript">
$(function(){
var html= $(".page")[0].innerHTML;
$.ajax({
cache : false,
type : "POST",
url : "file.php",
data : "html="+html,
dateType : "text"
});
});
</script>
</head>
<body>
<div class="page">
<span>more>></span>
<div>other infos</div>
</div>
</body>
</html>
file.php 文件:<?php
$html=$_POST['html'];
$file=fopen('result.html','w');
fwrite($file,$html);
fclose(file);
?>
打开test.html,jquery的ajax通过file.php生成的result.html中的代码只有<span>more后面的全没了,为什么会这样?怎么解决?
解决方案 »
- 高手进:zend studio中如何安装redis扩展
- 关于php做游戏索引问题
- 使用phpmyadmin用root帐户登陆后 添加新用户 ,出现1045错误
- 在 SMARTY 中,文章的点击量,应该怎么处理?
- 谁帮我解释一下这段话是什么意思啊
- 怎么用include()调用页脚并让页脚显示在网页最下边页脚处??
- 【help】red hat 新手 安装问题
- optional_param('cal_y', 0, PARAM_INT),这个函数的作用是什么
- 新手问有关文件的修改简单问题
- 关于手机短信接口的问题~~~
- [分享] PHP CURL 下载YOUTUBE影片到电脑(JUST TEST)
- PHPmailer 发信时间过长,有否解决方法?(其他发邮件方式请提出)
$(function(){
$.ajax({
cache : false,
type : "POST",
url : "file.php",
data : {html:$(".page:eq(0)").html()},//如果只有一个.page可以去掉:eq(0)
dateType : "text"
});
});
这样试试呢?
你如果一定要直接用>的话可以在php中$html = str_replace('>','>',$html);
http://bbs.phpchina.com/thread-170942-1-1.html