Fad
Fad

Reputation: 9858

jQuery .load() keep requesting page indefinitely

I have a checkbox where when it's clicked, .load() will be called. The requested page loads just fine except that jQuery keeps requesting page over and over again.

<script type="text/javascript">
    $(document).ready(function($) {
          $('#we').click(function() {
            $('#we_div').load('/form_url');
          });
        });
</script>
<div id="we_div" style="float:right;"><input type="checkbox" id="we"  /><label for="we">Some dummy text here.</label></div>

Can anyone tell me what's wrong with this?

Upvotes: 1

Views: 893

Answers (2)

mplungjan
mplungjan

Reputation: 177965

@Shef gave the idea. Try this safer method

<script type="text/javascript">
    $(document).ready(function($) {
          $('#we').click(function() {
            $('#we_div').load('/form_url',function() {
               $('#chk_span').hide();
            });
          });
        });
</script>
<div style="float:right;"><div id="we_div"></div><span id="chk_span"><input type="checkbox" id="we"  /><label for="we">Some dummy text here.</label></span></div>

Upvotes: 1

Sjoerd
Sjoerd

Reputation: 75609

Perhaps /form_url also contain this script to load /form_url.

Upvotes: 0

Related Questions