1

我正在学习 j 查询,我想在当前 URL 中发送 id,然后 UL Li 在点击事件上发送当前 URL 中的 id 而无需刷新页面

像这样:

Current URL = localhost/backupapp-latest-21-05/index.php?r=site/Application<br>
send id url = localhost/backupapp-latest-21-05/index.php?r=site/Application&abcid=48

有一个abcid=48是我的 UL Li id

试试这个代码:

$(document).ready(function(e) {
   $('#hari-ul > li').each(function(index, element) {

      $(element).click(function(e) {
         var id = (this.id);
         window.location.href  = "index.php?r=site/Application&abcid="+id;

      }
    });
  });
});

此代码在 URL 中发送 id 但页面刷新,我想要没有页面刷新的 id

4

1 回答 1

1

试试这个方法:

$.ajax({
  url: url,
  data: data,
  success: success,
  dataType: dataType
});

在此处查看示例:

在这里检查

或尝试这种方式:

$.get('path/to/yourfile.html', function(data) {
  //do something
});
于 2012-05-21T08:17:09.693 回答