0

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?

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Rishabh
  • 338
  • 1
  • 3
  • 17

1 Answers1

0

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() {

Vistari
  • 697
  • 9
  • 21