简体   繁体   English

javascript超链接

[英]javascript hyperlink

Hi I have written a abcd.ftl page which is beeing called in another defg.page The abcd.flg page has the fallowing code 嗨,我已经写了一个abcd.ftl页面,该页面在另一个defg.page中被调用。abcd.flg页面具有以下代码

 <div class="partnerOptInBox">
        <div id="optInContent">
            <form name="partnerOptIn">
                <h4>Want the Latest</h4>
                <p class="pad10Top">${partnerOpt.translation}</p>
                <div class="pad10Top">
                <input type="radio" name="questionAnswer['${partnerOpt.questionId}']" value="${partnerOpt.getAnswers()[0].answerId}" class="radioButton" /> <label for="questionAnswer['${partnerOpt.questionId}']" class="formLabel pad20Right">Yes</label> <input type="radio" name="questionAnswer['${partnerOpt.questionId}']" class="radioButton" value="${partnerOpt.getAnswers()[1].answerId}" /> <label for="questionAnswer['${partnerOpt.questionId}']" class="formLabel">No</label>
                </div>
                <div id="optInError" class="formError" style="display:none;">Oops... your request did not go through, please try again.</div>
                <div class="pad15Top">
                    <a href="javascript:submitOptIn();"><img src="images/theme/btn_opt_in_submit.gif"/></a>
                </div>                         
            </form>
            <script type="text/javascript">
function submitOptIn() {
    $('optInError').hide();
    dataString = $('#partnerOptIn').serialize();
    $.ajax({
        data: dataString,
        url: partnerOpt.do,
        timeout: 30000,
        type: "POST",
       success: function(html){
            var newHtml = "<h4>Thank you</h4><p>We appreciate your time to respond to our request.</p>";
            $('#optInContent').html(newHtml);
    },
        error: function(){
            $('#optInError').show();
        }
    });
}
</script>

        </div>
    </div>

But when I am clicking the submit button on this page its throwing a error saying "javascript:submitOptIn" not defined can any one please let me know what would be the reason for this error asap please THank you 但是,当我单击此页面上的“提交”按钮时,它抛出一个错误,提示“ javascript:submitOptIn”未定义,任何人都可以请让我知道此错误的原因是什么,请谢谢

我认为您应该将script标记放在页面的顶部。

javascript是否不必包含在{literal}中?

All jQuery scripts should be placed inside the "document.load" event to ensure that the DOM has loaded. 所有jQuery脚本都应放置在“ document.load”事件中,以确保已加载DOM。 Try to place your scripts inside: 尝试将脚本放入其中:

$(function() {

   // place your scripts here

});

The code DOES work on IE6, IE7, FF and Chrome... 该代码可在IE6,IE7,FF和Chrome上运行。
It's all the code you posted in the defg.page, or are you calling it from the abcd.ftl page? 这是您在defg.page中发布的所有代码,还是从abcd.ftl页面调用它?

尝试:

<a href="#" onClick="javascript:submitOptIn();">...</a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM