我在 javascript 字典中存储了一些键和值
var list_of_addressbook_entries = {};
我在一个 php 页面上传递那个字典
但是当我试图获取 javascript dict 的键和值时
$attendee_list = $_POST['dict_of_externals'];
$shared_attendee_list = $_POST['list_of_shared_addressbook_entries'];
$org_attendee_list = $_POST['dict_of_org_users'];
echo json_encode($attendee_list);
return false;
作为回应,我只得到"[object Object]"
我只想知道如何在 php 中提取值?
在我的 javascript
for(key in list_of_addressbook_entries)
{
alert("key " + key
+ " has value "
+ list_of_addressbook_entries[key]);
}
正在打印键和值
更新
var list_of_addressbook_entries_privilege = [];
function showDetails(guest_name){
var user_name = "<?php echo $_SESSION["user_name"]; ?>" ;
var name = prompt("Please use M for moderator and A for attendee", "Type you name here");
if (!name == null && !name== '' || name == 'M' || name == 'A'){
var ahtml='<div id ="div_id_'+guest_name+'" onclick =remove_addressbook_user("'+guest_name+'") class="addr_list" style="display:block; background: none repeat scroll 0% 0% peachpuff;margin-bottom:1px;">'
ahtml = ahtml + '<span>'+guest_name+'</span>'
ahtml = ahtml + '<input type = "hidden" id ="user_id_'+guest_name+'" value = "'+guest_name+'" /></div>'
$(".address_book_list").append(ahtml);
$("#div_id_"+guest_name).hide();
list_of_addressbook_entries[guest_name] = name ;
}
else{
alert("You have entered the worong value ");
return false;
}
$('#dict_of_externals').val(list_of_addressbook_entries);
for(key in list_of_addressbook_entries)
{
alert("key " + key
+ " has value "
+ list_of_addressbook_entries[key]);
}
}