我目前正在做一个系统,必须能够选中/取消选中一个复选框.每当它改变状态我需要
jquery来制作和ajax
调用页面,这会更新
数据库.
我的问题是 – 我怎么能这样做,所以它更新?
提前致谢.
例如,您可以这样做:
首先,您必须查看是否选中了复选框:
- $("#yourSelector").live("click",function(){
- var id = parseInt($(this).val(),10);
- if($(this).is(":checked")) {
- // checkBox is checked -> do something
- } else {
- // checkBox is not checked -> do something different
- }
- });
您可以通过Ajax加载特定内容:
- $.ajax({
- type: "POST",dataType: "xml",url: "path/to/file.PHP",data: "function=loadContent&id=" + id,success: function(xml) {
- // success function is called when data came back
- // for example: get your content and display it on your site
- }
- });