如何在点击事件上调用jQuery AJAX?

zod*_*zod 6 jquery jquery-ui

我做了一个jQuery模型.

我试图在该模型中使用AJAX填充数据.

我得到一个id并使用我想用AJAX填充数据.

如何在点击事件上调用AJAX?

打开或加载模型时是否还有其他事件?

该模型只是div的显示和隐藏.

Gar*_*ero 10

简单地使用:

JS:

$(document).ready(function(){
  $('a.pop').click(function() { 
    var popID = $(this).attr('rel');
    $.get('content.php', { ref:popID }, function(data) {
       $(popID+'Container').html(data);
       $(popID).dialog();
       alert('Load was performed.');
    });
    return false; // prevent default
  });
});
Run Code Online (Sandbox Code Playgroud)

HTML:

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

它没有经过测试,但正如我所看到的,它应该可以工作......