gpt4 book ai didi

javascript - 如何将变量传递给 .post()?

转载 作者:行者123 更新时间:2023-11-30 10:49:09 24 4
gpt4 key购买 nike

我有这样的东西......

$().ready(function () {

$(".post .comment_this").click(function () {

var comment_id = $(this).attr('rel');

$.post(url_base + 'bio/community/get_comments', { 'comment_id' : comment_id }, function (response) {

console.log(comment_id);

});

});

});

如何将 comment_id 传递给该函数?所以我可以在那里使用它...

最佳答案

你可以在那里毫无问题地使用它。

在 Javascript 中,您可以访问作用域链中定义的每个变量,直至全局作用域。本地定义的变量将覆盖来自链的变量。

JavaScript Variable Scope on SO

关于javascript - 如何将变量传递给 .post()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6545206/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com