簡體   English   中英

請幫我用HTML輸出替換一些JavaScript

[英]Please help me replace some javascript with html output

我的頁面上有一個Mailchimp電子郵件注冊表格。 當成功或失敗的注冊發生時,它會從javascript庫中獲取成功/失敗消息。

我想停止它,以獲取默認消息(我無法編輯這些消息,因為我認為它們位於Mailchimp的服務器上)並用我自己的消息替換。 你能幫我嗎?

這是相關的功能:

function mce_success_cb(resp){
$('#mce-success-response').hide();
$('#mce-error-response').hide();
if (resp.result=="success"){
    $('#mce-'+resp.result+'-response').show();
    $('#mce-'+resp.result+'-response').html(resp.msg);
    $('#mc-embedded-subscribe-form').each(function(){
        this.reset();
    });
} else {
    var index = -1;
    var msg;
    try {
        var parts = resp.msg.split(' - ',2);
        if (parts[1]==undefined){
            msg = resp.msg;
        } else {
            i = parseInt(parts[0]);
            if (i.toString() == parts[0]){
                index = parts[0];
                msg = parts[1];
            } else {
                index = -1;
                msg = resp.msg;
            }
        }
    } catch(e){
        index = -1;
        msg = resp.msg;
    }
    try{
        if (index== -1){
            $('#mce-'+resp.result+'-response').show();
            $('#mce-'+resp.result+'-response').html(msg);            
        } else {
            err_id = 'mce_tmp_error_msg';
            html = '<div id="'+err_id+'" style="'+err_style+'"> '+msg+'</div>';

            var input_id = '#mc_embed_signup';
            var f = $(input_id);
            if (ftypes[index]=='address'){
                input_id = '#mce-'+fnames[index]+'-addr1';
                f = $(input_id).parent().parent().get(0);
            } else if (ftypes[index]=='date'){
                input_id = '#mce-'+fnames[index]+'-month';
                f = $(input_id).parent().parent().get(0);
            } else {
                input_id = '#mce-'+fnames[index];
                f = $().parent(input_id).get(0);
            }
            if (f){
                $(f).append(html);
                $(input_id).focus();
            } else {
                $('#mce-'+resp.result+'-response').show();
                $('#mce-'+resp.result+'-response').html(msg);
            }
        }
    } catch(e){
        $('#mce-'+resp.result+'-response').show();
        $('#mce-'+resp.result+'-response').html(msg);
    }
}

}

我認為在任何地方您都可以看到以下內容:

$('#mce-'+resp.result+'-response').html(msg);

您想根據自己的邏輯位置將msg部分替換為相關文本。 因此,您發布的代碼中的第一個(第6行)是成功= true,因此請替換

$('#mce-'+resp.result+'-response').html(resp.msg);

用類似的東西

$('#mce-'+resp.result+'-response').html('Successfully signed up');

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM