使用Jquery传递带参数的链接
我有这个链接:
#
我想通过Jquery传递它,因此页面不会刷新。 但是,我很难实现这一目标。 我用Jquery尝试过的所有点击事件和ajax都没有成功。
基本上,我希望ajax发送delete.php iid参数中的值。
在这里试试这个href='https://stackoverflow.com/questions/10369432/passing-link-with-parameters-with-jquery/1'
是你要删除的id,也是为了替换它找到id="dhttps://stackoverflow.com/questions/10369432/passing-link-with-parameters-with-jquery/1"
的文本:
Delete Delete Delete Delete
$(function(){ $("#delete").click(function(e){ e.preventDefault(); $.post("../add/delete.php", { iid: "xxx" } ,function(data){ //do whatever with the result which is in the variable data. alert(data) }); }); });
由于它是删除,请使用POST。 否则,一些抓取工具会抓取您的删除页面,并且您会在早上看到您的表格为空。
编辑 :您可以将要传递的值与锚标记相关联。 例如:将您的id标签更改为此格式del-YouIdTobe已删除(例如:del-https://stackoverflow.com/questions/10369432/passing-link-with-parameters-with-jquery/1,del-https://stackoverflow.com/questions/10369432/passing-link-with-parameters-with-jquery/2等…)
Delte https://stackoverflow.com/questions/10369432/passing-link-with-parameters-with-jquery/2