【发布时间】:2018-02-18 10:07:05
【问题描述】:
我创建 js 对象:
var taskTypes = {};
$(".task_types_tags_category").each(function () {
var name = $(this).attr("name");
name = name.replace("[]","");
var typeId = $(this).val();
var currentTagsCount =0;
var currentTags = [];
if($(this).is(":checked")){
taskTypes[typeId]={};
taskTypes[typeId]=[typeId];
}
$('input[name="'+name+'[task_types_tags][]"]').each(function () {
if($(this).is(":checked")){
currentTags.push($(this).val());
++currentTagsCount;
}
});
if(currentTagsCount >0){
taskTypes[typeId]={};
taskTypes[typeId]=[typeId];
taskTypes[typeId]["tags"]={};
taskTypes[typeId].tags = currentTags;
}
});
console.log(taskTypes);
我需要将 taskTypes 对象传递给 php。
在控制台中,我得到了正确的对象:
https://clip2net.com/s/3RZXM4b
然后我尝试传递对象:
$.post(sJSUrlSaveLeadNote, {taskTypes:taskTypes},
function (data) {
}, "json");
php 文件:
show($_REQUEST['taskTypes']);
但在 php 中我只是得到它(无法获取标签键): https://clip2net.com/s/3RZXQaK
我该如何解决?谢谢。
【问题讨论】:
-
JSON.stringify( taskTypes )?
标签: javascript php jquery ajax object