开发者

scriptaculous, prototype problem

The code mentioned below works fine locally,

<script type="text/javascript" src="lib/prototype.js"></script>
<script type="text/javascript" src=开发者_StackOverflow"src/scriptaculous.js"></script>
<script type="text/javascript">
window.onload = function() {
    new Ajax.Autocompleter("empName","empNameOptions","empAutoComplete.jsp", {
        afterUpdateElement : getSelectionId,indicator: 'indicator1'
    });

    function getSelectionId(text, li) {
        $('empIdTT').value=li.id;
    }
}
</script>

BUT when I call the code from server (windows 2008), the .js apparently does not load at all, but when assign a new url for js the code works normal.

<script type="text/javascript" src="http://www.someSite/lib/prototype.js"></script>
<script type="text/javascript" src="http://www.someSite/src/scriptaculous.js"></script>

what happen to the server? is there any configuration I must do it?

Note: I use tomcat and JSP technique Please help


In code snippet #1 the src is relative. Turn these to absolute paths and you're good (i.e. write src="/lib/prototype.js").

Note: you're using prototype, so instead of assigning an anonymous function to window.onload, do:

document.observe('dom:loaded', function() {
    // insert code here
});

This will allow for multiple functions running, when the DOM has been set up.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜