質問

I load a div dynamically with jquery .load() function. I am calling a jsp in which I I performing an operation on window.onload = function() { //some operation} and $(window).unload(function(){//some operation; anotherFunction();})

Now, the problem is that these operations are not being executed, but the call to anotherFunction() is made! I simply put an alert() before the function call and the alert won't fire, whereas the alert that I put inside anotherfunction() will be fired.

I have some javascript code that I have written in $(document).ready(function(){//some javascript code;}). None of my operation in the ready() function gets done when I load the jsp using .load().

all the above operations are working fine when I use <jsp:include page="myPage.jsp"></jsp:include>

does anyone have any idea why .load() would work this way?

役に立ちましたか?

解決

My experience with JSP isn't great but I know a fair bit about Javascript and PHP so I assume this will work on a similar principle.

Are you using an onClick listener so for example $("SELECTOR").click(function(){

If so then I think try this for example instead:

$(document).on('click', "SELECTOR", function() {

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top