web開發1-fckeditor部署報錯:The server didn't reply with a proper XML data.


在部署fckeditor的時候可能遇到各種各樣的問題,很容易就在網上搜到答案的可能大家不會在乎,我遇到的糾結了很長時間在搞定,走了一些彎路。

先看看問題。部署好之后上傳圖片的時候瀏覽本地文件的時候出錯。火狐錯誤界面如下圖1

圖1

這個圖給的信息是假象,通過信息可以找到報錯的代碼\fckeditor\editor\filemanager\browser\default\js\fckxml.js,

代碼如下:

FCKXml.prototype.LoadUrl = function( urlToCall, asyncFunctionPointer )
{
    var oFCKXml = this ;

    var bAsync = ( typeof(asyncFunctionPointer) == 'function' ) ;

    var oXmlHttp = this.GetHttpRequest() ;

    oXmlHttp.open( "GET", urlToCall, bAsync ) ;

    if ( bAsync )
    {
        oXmlHttp.onreadystatechange = function()
        {
            if ( oXmlHttp.readyState == 4 )
            {
                var oXml ;
                try
                {
                    // this is the same test for an FF2 bug as in fckxml_gecko.js
                    // but we've moved the responseXML assignment into the try{}
                    // so we don't even have to check the return status codes.
                    var test = oXmlHttp.responseXML.firstChild ;
                    oXml = oXmlHttp.responseXML ;
                }
                catch ( e )
                {
                    try
                    {
                        oXml = (new DOMParser()).parseFromString( oXmlHttp.responseText, 'text/xml' ) ;
                    }
                    catch ( e ) {}
                }

                if ( !oXml || !oXml.firstChild || oXml.firstChild.nodeName == 'parsererror' )
                {
                    alert( 'The server didn\'t send back a proper XML response. Please contact your system administrator.\n\n' +
                            'XML request error: ' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')\n\n' +
                            'Requested URL:\n' + urlToCall + '\n\n' +
                            'Response text:\n' + oXmlHttp.responseText ) ;
                    return ;
                }

                oFCKXml.DOMDocument = oXml ;
                asyncFunctionPointer( oFCKXml ) ;
            }
        }
    }

    oXmlHttp.send( null ) ;

    if ( ! bAsync )
    {
        if ( oXmlHttp.status == 200 || oXmlHttp.status == 304 )
            this.DOMDocument = oXmlHttp.responseXML ;
        else
        {
            alert( 'XML request error: ' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')' ) ;
        }
    }
}

在網上很多人在這段代碼里面找原因,圍繞着這一段代碼修改,並且解決了問題 ,但是很不幸,除了我之外,我也在這段代碼里面縫縫補補,最后問題還是存在。

在IE瀏覽器里面報錯更加詳細,其實在火狐里面如果跟進去也可以看到這個詳細的報錯信息,如下圖2。

圖2

最關鍵的信息是:Error calling [msvcrt.dll]:_wnkdir(c:\input\wwwroot\fckfiles),error code:-1
注意到fckfiles是我自己新建的一個文件夾,放在和fckeditor平行的一個目錄下,怎么會出現在“c:\input\wwwroot\fckfiles”這樣的一個路徑下呢,很明顯是配置文件里面配置上傳圖片文件的目錄時出錯了。

將<add key="FCKeditor:UserFilesPath" value="/fckfiles/"/>修改為<add key="FCKeditor:UserFilesPath" value="~/fckfiles/"/>最后解決問題。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM