Javascript 带ID的CallAjax

Javascript 带ID的CallAjax,javascript,jquery,ajax,Javascript,Jquery,Ajax,如何将ID添加到Ajax: function callAjax() { jQuery.ajax({ type: "GET", url: "topics.php?action=details&id=", cache: false, success: function(res){ jQuery('#ajaxcontent').html(res); } });

如何将ID添加到Ajax:

    function callAjax()
{
    jQuery.ajax({
        type: "GET",
        url: "topics.php?action=details&id=",
        cache: false,
        success: function(res){
                jQuery('#ajaxcontent').html(res);
        }
    });
}
与:

<a href="javascript:;" id="'.$row['id'].'" class="button" onclick="callAjax();">'.$row['post_title'].'</a>


提前感谢您的支持。

尝试添加

data: { id: "MyIdHere" },
。。。然后,将此数据格式化并作为GET的一部分正确发送

这可以从URL中删除。。。并作为数据的一部分添加:

?action=details&id=
。。。像这样

data: { action: "details", id: "MyIdHere" },
尝试添加

data: { id: "MyIdHere" },
。。。然后,将此数据格式化并作为GET的一部分正确发送

这可以从URL中删除。。。并作为数据的一部分添加:

?action=details&id=
。。。像这样

data: { action: "details", id: "MyIdHere" },
您可以使用:

url: "topics.php?action=details&id="+$('a').attr('id'),
如果希望它发送数据,请使用以下命令:

jQuery.ajax({
        type: "GET",
        url: "topics.php",
      data: { action: "details", id: $('a').attr('id') },
        cache: false,
        success: function(res){
                jQuery('#ajaxcontent').html(res);
        }
    });
您可以使用:

url: "topics.php?action=details&id="+$('a').attr('id'),
如果希望它发送数据,请使用以下命令:

jQuery.ajax({
        type: "GET",
        url: "topics.php",
      data: { action: "details", id: $('a').attr('id') },
        cache: false,
        success: function(res){
                jQuery('#ajaxcontent').html(res);
        }
    });

我强烈建议你阅读这本书。希望它能帮助您学习jQuery的基础知识。我强烈建议您阅读。希望它能帮助您学习jQuery的基础知识。