zod zod - 1 year ago 86
jQuery Question

How to call jQuery AJAX on click event?

I made a jQuery model.

Am trying to populate data using AJAX inside that model.

I am getting an id and using that I want to populate data using AJAX.

How should I call AJAX on click event?

Is there any other event when the model is opened or loaded?

The model is just the showing and hiding of div.

Answer Source

Simply using:


  $('a.pop').click(function() { 
    var popID = $(this).attr('rel');
    $.get('content.php', { ref:popID }, function(data) {
       alert('Load was performed.');
    return false; // prevent default


<div id="example" class="flora" title="This is my title">
    I'm in a dialog!
    <div id="exampleContainer"></div>
<a href="#" id="clickingEvent" class="pop" rel="example">click to launch</a>

It is not tested, but as I see it, it should work...

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download