如何使用 ajax 从选定行获取 ID

How to get id from selected row using ajax

我有两个页面,第一页可以查看信息,单击行的编辑图标将转到第二页,其中包含显示数据的 ID。第二页显示数据后,您可以更新数据等

button click getting id in view file code

view file code

edit file code

您可以从 Url.Use 这个 id 中获取 id 并通过 ajax on call $( window ).load(function() {// Run code});.

在编辑表单中填写数据
 var getUrlParameter = function getUrlParameter(sParam) {
            var sPageURL = window.location.search.substring(1),
                sURLVariables = sPageURL.split('&'),
                sParameterName,
                i;
  for (i = 0; i < sURLVariables.length; i++) {
            sParameterName = sURLVariables[i].split('=');

            if (sParameterName[0] === sParam) {
                return sParameterName[1] === undefined ? true : 
            decodeURIComponent(sParameterName[1]);
            }
        }
    };

    id = getUrlParameter('Edit');
    console.log(id);//check console