0

i tried to load a page inside a div tag using a script,the page is a login page,when i logged in i need to open the corresponding output page inside the same div,i dont have any idea how to proceed further because it is two different pages which should opened one after the other

<script>
$(document).ready(function() {
$(".link1").click(function(event){
   event.preventDefault();
   var url =$(this).attr("href");
   $('#clear').load(url);
});
});
</script>

the above script will load the login page inside the div tag

<a class="link1" href="display.jsp">link to open the login page</a>

the corresponding page after the login contains table which should be displayed in the same div.

ksa
  • 311
  • 1
  • 10
  • 29

1 Answers1

0

You have to disable the default-behaviour so that the browser doesn't navigate: either by return false; or by event.preventDefault(), see this thread

Community
  • 1
  • 1
rollstuhlfahrer
  • 3,988
  • 9
  • 25
  • 38
  • i tried disabling it,the page is opening in another window as well as inside the div – ksa Aug 14 '12 at 06:27
  • Even with `target="_blank"` my example works as expected. See: http://jsfiddle.net/j5J7G/3/ – rollstuhlfahrer Aug 14 '12 at 07:21
  • it shows the first page(that is my login page),after clicking the login button it should display a table from another page,to be specific i want my div to work like a iframe – ksa Aug 14 '12 at 08:51
  • Is that why the second window appears? – rollstuhlfahrer Aug 14 '12 at 09:32
  • ya after submitting the form the second window should be displayed within the div.it is possible to do so?like we do in iframe. – ksa Aug 14 '12 at 09:35
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/15326/discussion-between-ksa-and-rollstuhlfahrer) – ksa Aug 14 '12 at 09:38