日期:2014-05-18  浏览次数:20396 次

关于fckedit 和 ajax 的问题
JScript code

function autotag2(){ 

      var title = document.forms["myform"].txtTitle.value; 
//    var Message = document.forms["myform"].LogContent.value; 
      var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;
      document.getElementById('hf_FCKEditor1').value=oEditor.GetXHTML();
      debugger;
      var Message =document.forms["myform"].hf_FCKEditor1.value;

    var Str="title=" + escape(title) + "&Message=" + escape(Message) + "&m=" + Math.random(); 
    document.forms["myform"].atuotag.disabled = true; 
    if (title.length < 1) { 
        alert("错误提示:没有填写标题!    "); 
        document.forms["myform"].atuotag.disabled = false; 
        return false 
    } 
    if (Message.length < 1) { 
        alert("错误提示:内容不能为空!    "); 
        document.forms["myform"].atuotag.disabled = false; 
        return false 
    } 
    else { 
        if (window.ActiveXObject) { 
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); 
        } 
        else if (window.XMLHttpRequest) { 
            xmlHttp = new XMLHttpRequest(); 
        } 
        var url = "/ajaxmethod/tags.aspx?Action=jiu"; 
        var query="title=" + escape(title) + "&Message=" + escape(Message) + "&m=" + Math.random(); 
        xmlHttp.onreadystatechange = function() { 
            if(xmlHttp.readyState == 4) { 
                if(xmlHttp.status == 200) { 
                    var TempStr = xmlHttp.responseText; 
                    document.forms["myform"].atuotag.disabled = false; 
                    if (TempStr == 0) { 
                        alert("没有找到可用!") 
                    } else { 
                        document.forms["myform"].txtTags.value += TempStr 
                    } 
                } 
                else{ 
                //alert("Ajax无返回!") 
                } 
            } 
        } 
        xmlHttp.open("POST", url, true); 
        xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
        xmlHttp.send(query); //Ajax技术中的xmlhttp.send()方法提供我们传送大量数据的功能
    } 
} 
  
</script> 




以上 var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;
  document.getElementById('hf_FCKEditor1').value=oEditor.GetXHTML();如果不用fckedit 直接用textbox没有任何问题。这里fckedit取值也没问题。问题是用了fck之后ajax提交不到后台了。一直在js里跳,到xmlHttp.readyState == 4的时候还转入到fck的API里去了。是在搞不懂啊!!!

------解决方案--------------------
学习,谢谢,有学到知识了
------解决方案--------------------
$get("hf_FCKEditor1").value=FCKeditorAPI.GetInstance('FCKeditor1').GetXHTML(true);
判断值是否为 空
return false
再使用ajax异步查询ashx获取数据

------解决方案--------------------
顶下. 回复内容太短了
------解决方案--------------------
string ret = Request.Params["Message"].ToString();
Response.Write(ret);
Response.End();

上面红色这句加了没有?
------解决方案--------------------
学习。。。 那次搞这个fck一夜都没整好。 苦死我了!!
------解决方案--------------------
不会。。。。。帮顶!
------解决方案--------------------
不知道,帮顶,在用ckeditor(fck3.0以后的版本)
var oEditor = CKEDITOR.instances.id; var content=oEditor.getData();这样用没问题。
如果有js高手在的话请帮忙解决下http://topic.csdn.net/u/20100224/16/e5f1e75e-974a-4a4b-a62a-a8c821f6dd0b.htmlIE中光标感应不灵敏这个问题,谢谢。