gpt4 book ai didi

php - 使用 ajax 从链接获取 $_GET 值

转载 作者:行者123 更新时间:2023-11-28 09:17:34 25 4
gpt4 key购买 nike

我为我的脚本做了一个设置页面...并以设置 a 的形式做到了这一点

<form action='javascript:insert()'>

然后我得到输入或复选框上插入的所有值或任何以 JavaScript 设置形式的值。就像:

function insert() {
// Optional: Show a waiting message in the layer with ID login_response
document.getElementById('huemix_message').innerHTML = "<img src='images/saver.gif' />"
// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
var system_name= encodeURI(document.getElementById('system_name').value);
var system_logo = encodeURI(document.getElementById('system_logo').value);
var system_number = encodeURI(document.getElementById('system_number').value);
var system_tel = encodeURI(document.getElementById('system_tel').value);
if($("#system_pics").is(':checked')){
var system_pics = 1;
} else {
var system_pics = 0;
}
if($("#system_bread").is(':checked')){
var system_bread = 1;
} else {
var system_bread = 0;
}

// Set te random number to add to URL request
nocache = Math.random();
// Pass the login variables like URL variable
http.open('get', 'huemixpanel_insert.php?system_name='+system_name+'&system_logo='+system_logo+'&system_number='+system_number+'&system_tel='+system_tel+'&system_pics='+system_pics+'&system_bread='+system_bread+'&uid='+uid+'&nocache = '+nocache);
http.onreadystatechange = insertReply;
http.send(null);
}

一切都工作正常..我使用 ajax 将所有值发送到另一个 php 页面以更新我的数据库现在我的问题是:

在同一页面中,我有一个部分可以编辑我的成员..我正在使用 "SELECT * FROM ..." 显示我的成员(member)列表结果显示如下:

MEMBER    DEPARTMENT   ACCESS EDIT

admin admin all edit
user2 service service edit

“编辑”一词是一个链接,例如:

<a href='hueimx.php?action=edit&uid={$result['uid']}'>edit</a>

“{$result['uid']}”这是从数据库获取的客户ID

所以管理员用户的“编辑”词链接就像这样

<a href='huemix.php?action=edit?uid=1'>edit</a>

我想将生成的 [uid] 从数据库发送到我的 javascript 页面

并将 uid 值放入 ajax 函数中的变量中,将其发送到另一个 php 文件以更新我的数据库,,, 如何??

最佳答案

不要将其添加为 href,而是将其添加到 js 函数中的 onclick -

<a href="#" onclick="edit_action({$result['uid']})">edit</a>

并在 js 中创建一个函数 -

function edit_action(uid) {
//send it to php.
}

关于php - 使用 ajax 从链接获取 $_GET 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15450987/

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