在DEDE上加功能,遇到几个问题,想实现的功能就是ajax post编辑器中的数据到当前页面,然后进行一些处理再返回放到编辑器中
js 代码如下
function weiyuanchuang(){
var myeditor = FCKeditorAPI.GetInstance('body');
var content = myeditor.EditorDocument.body.innerHTML;
//alert(content);
var url = "?";
content=encodeURI(content);
var postStr = "dopost=weiyuanc&content="+content;
xmlHttp = GetXmlHttpRequest(); 
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
xmlHttp.onreadystatechange = replaceContent; 
    xmlHttp.send(postStr); 
}function replaceContent(){
if(xmlHttp.readyState == 4 && xmlHttp.status == 200)
    {
var response = xmlHttp.responseText;
var myeditor = FCKeditorAPI.GetInstance('body');
SetEditorContents("body",response);
}
}
用url编码方式提交的,抓包看到提交的数据也确实url编码过,然后PHP页面取值,直接echo $_POST["content"]发现当有 #&  等一些特殊字符的时候内容就会被截断,我明明url编码过的,为什么还会截断呢?PHP代码如下
if($dopost=='weiyuanc')
{
//echo $_REQUEST["content"]; die();
$sql = "select * from stream_weiyuanc";
$dsql->SetQuery($sql);
$dsql->Execute();
$content = stripslashes(iconv ("utf-8","GBK",urldecode($_POST["content"])));
$i=0;
$oriArray = array();
$replaceArray  = array();
while($row = $dsql->GetArray()){   
$oriArray[$i] = "/".$row['oriTitle']."/";
$replaceArray[$i] =  $row['replaceTitle'];   
$i++;

echo preg_replace($oriArray,$replaceArray,$content);
exit();
}
我以为是转码时候截断的,但我直接//echo $_REQUEST["content"]; die();发现这里就断了。为什么呢?