【问题标题】:how to post id in current URL using Jquery?如何使用 Jquery 在当前 URL 中发布 id?
【发布时间】:2012-05-21 07:56:54
【问题描述】:

我正在学习 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

【问题讨论】:

标签: javascript jquery-ui jquery html-lists sendkeys


【解决方案1】:

试试这个方法:

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

在此处查看示例:

Check here

或者试试这个方法:

$.get('path/to/yourfile.html', function(data) {
  //do something
});

【讨论】:

  • 我已经尝试过这段代码,但它的 con 没有在我的 j 查询中运行我想要另一个示例 j 查询代码
猜你喜欢
  • 1970-01-01
  • 2021-07-31
  • 2014-09-30
  • 1970-01-01
  • 2013-08-10
  • 2010-09-29
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多