0

I have created a page using html, ajax and jQuery. In this page I have a div and a button. When I click the button, this button gets some data from another page, using jQuery and ajax, and load those in the div. That is correct. The problem is that when I type the url and open the page, the div form does show me nothing. Then when I click the button, the dic shows me the results.

What I am writing for is that I want to show the result in the div when I initialize the page. I mean, I type url and the page should show me the result in the div by default. Can you provide me any solution?

loren
  • 1
  • 4

2 Answers2

0

Try moving the click event handler in the button onto the $(document).ready

user70585
  • 1,397
  • 1
  • 14
  • 19
0

You can do the ajax thing using jQuery
$(document).ready(function(){ //Your ajax code here });
As soon as the DOM is ready i.e. completely loaded the ajax would be called and the answer would be shown as you want..
Hopefully it helps.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Bhavik
  • 4,836
  • 3
  • 30
  • 45