我的PHP代码中的未定义索引。 [英] Undefined Index in my PHP code.
本文介绍了我的PHP代码中的未定义索引。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
//Why is that I cant retrieve the value of UserID from my JavaScript code to PHP, it says that "Undefined index: userID"
//this is my Code
//JavaScript CODE
function Print(str) {
var userID = str;
$.ajax({
type: "POST",
url: 'ROOMS.php',
data: { userID : userID },
success: function(data)
{
alert("success!");
}
});
}
//PHP CODE
<?php
$id = $_POST['userID'];
echo $id;
?>
推荐答案
.ajax({
类型: POST,
url:' ROOMS.php',
data:{userID:userID},
success:function(data)
{
alert( success!);
}
});
}
// PHP代码
<?php
.ajax({ type: "POST", url: 'ROOMS.php', data: { userID : userID }, success: function(data) { alert("success!"); } }); } //PHP CODE <?php
>
id =
id =
_POST [' userID' 跨度>];
echo
_POST['userID']; echo
这篇关于我的PHP代码中的未定义索引。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文