1

您好,我遇到了编码失败的问题。谁能发现我哪里出错了?

<form>
    <table cellspacing="0" cellpadding="0" border="0" style="background-color:#ededed;padding:50px;">
        <tr>
            <td align="left"><b>Screen? (eg. Index)</b></td>
        </tr>
        <tr>
            <td align="left"><input type="text" name="strFeedbackScreen" value="" style="width:300px;"></td>
        </tr>
        <tr>
            <td style="height:10px"></td>
        </tr>
        <tr>
            <td align="left"><b>Comments:</b></td>
        </tr>
        <tr>
            <td align="left"><textarea name="strFeedbackComments" style="width:400px;height:150px;"></textarea></td>
        </tr>
        <tr>
            <td style="height:10px"></td>
        </tr>

        <tr>
            <td align="left"><b>Thank you for your feedback.</b></td>
        </tr>
        <tr>
            <td style="height:10px"></td>
        </tr>

        <cfoutput>

            <tr>
                <td align="left"><input type="button" value="Send" class="button" 
                    onMouseover="this.className = 'buttonover';" 
                    onMousedown="this.className = 'buttonover';" 
                    onMouseOut="this.className = 'button';" 
                    onclick="sendfeedback('strFeedbackScreen='+escape(this.form.strFeedbackScreen.value)+',strFeedbackComments='+escape(this.form.strFeedbackComments.value),'send_feedback_action_ajax')">
                </td>
            </tr>

        </cfoutput>

    </table>
</form>

是形式

<cfoutput>
    <cfmail to="feedback@example.com" from="feedback@example.com" subject="Feedback left" type="html">

        <table cellpadding="0" cellspacing="0" border="0">
            <tr>
                <td>**** This email has been sent to all concerned ****</td>
            </tr>
            <tr>
                <td style="height:10px;">&nbsp;</td>
            </tr>

            <cfif application.ds eq "App1">
                <tr>
                    <td>This feedback has been left on App 1.</td>
                </tr>
            <cfelseif application.ds eq "App2">
                <tr>
                    <td>This feedback has been left on App 2.</td>
                </tr>
            <cfelseif application.ds eq "App3">
                <tr>
                    <td>This feedback has been left on App 3.</td>
                </tr>
            </cfif>

            <tr>
                <td style="height:10px;">&nbsp;</td>
            </tr>
            <tr>
                <td><b>From:</b></td>
            </tr>
            <tr>
                <td>#session.stafffirstname# #session.staffsurname# - #session.staffemail#</td>
            </tr>
            <tr>
                <td style="height:10px;">&nbsp;</td>
            </tr>
            <tr>
                <td><b>Screen:</b></td>
            </tr>
            <tr>
                <td>#strFeedbackScreen#</td>
            </tr>
            <tr>
                <td style="height:10px;">&nbsp;</td>
            </tr>
            <tr>
                <td><b>Comments:</b></td>
            </tr>
            <tr>
                <td>#strFeedbackComments#</td>
            </tr>
        </table>

    </cfmail>
</cfoutput>    

是 action.cfm

和 javascript 是

function sendfeedback(fields,action) { 
    turnLayeron('ajaxloading');
    nocache = Math.random();
    http.open('get', '/ajax.cfm?action='+action+'&fields='+fields+'&nocache='+nocache);
    http.onreadystatechange = function() {
    if(http.readyState == 4){
        closepopout();  
            turnLayeroff('ajaxloading');
        }
    };
    http.send(null);
}

我一直在尝试让 uriencode 工作,但它在通过电子邮件发送之前对我的字符串进行了编码。

4

1 回答 1

2

将您的 JavaScript 更改为以下内容:

function sendfeedback(fields,action) {
    http.open("POST", '/ajax.cfm?action='+action+'&nocache='+nocache, true);
    http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http.onreadystatechange = function() {
        if(http.readyState == 4){
            closepopout();  
            turnLayeroff('ajaxloading');
        }
    };
    http.send(fields);
}

还将您的函数调用更改为:

onclick="sendfeedback('strFeedbackScreen='+escape(this.form.strFeedbackScreen.value)+'&strFeedbackComments='+escape(this.form.strFeedbackComments.value),'send_feedback_action_ajax')"

于 2012-11-06T03:43:15.370 回答