php - 如何使用ajax从选定的行中获取id
问题描述
我有两页,第一页您可以在其中查看信息,然后单击行的编辑图标,它将转到带有 id 的第二页以显示数据。第二页显示数据后,您可以更新数据等。
解决方案
您可以从 Url 获取 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
推荐阅读
- python-3.x - python中的main.py到底是什么,我如何使用它来使用pyinstaller创建一个可执行文件?
- c# - 为什么要使用 ReaderWriterLockSlim.EnterReadLock?
- ruby-on-rails - 使用现有的推文模型实现转推功能
- c++ - 函数 C++ 中的 Auto 变量出错
- python-3.x - 如果失败,如何退出python子进程
- android-security - Android 中的 Playstore 通知 HostnameVerifier 接口的不安全实现
- python - 在python中解析日期到日期时间格式
- if-statement - 在 prolog 中返回布尔值的嵌套 if 语句
- ruby-on-rails - Minitests 在纯函数上很不稳定,没有副作用
- angular - 为什么使用 `fakeAsync` 测试不会使测试代码以异步方式运行?