我在客户页面上有一个脚本
<a href='hueimx.php?action=edit&uid={$result['uid']}'>click to edit</a>
和
{$result['uid']}
这是我从数据库获取的客户ID。
现在我想在我的javascript页面上收到“uid”值。这是我的代码:
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);
}
在此页面中,我收到了设置页面中的所有值,并将其转发到php页面以将其插入数据库。一切正常,但我不知道如何收到“uid”值,并按照你的意愿发送。
答案 0 :(得分:0)
好吧,如果您的唯一目标是将数据从一个页面发送到另一个页面。然后,您可以通过在URL中附加数据来轻松完成此操作。在另一页上只需抓取数据并处理您的操作。
您的脚本非常适合发送数据。在另一页“ * huemixpanel_insert.php * ”中,请考虑添加以下代码:
<?php
if(!empty($_GET['uid']))
{
$uid = strip_tags($_GET['uid']); // check for security hole
//Your rest of the ***huemixpanel_insert.php*** code goes down here...
} else {
//You can die the rest of the page if uid is not received. (Optional) don't use else if you don't want to take any action.
}
?>