POSTED DATA是EMPTY,但为什么会这样。请检查!!!
function AData(mid,murl,mdata)
{
$.post( murl, mdata)
.done(function( data ) {
$("#res"+mid).html(data);
});
}
AData('1','http://api.techsoul.in/movies/techsoul-update-movies.php?token=777&fun=addmovie','{ detail:"PHA%2BTW92aWUgRGV0YWlscyBPZiA6IEFycml2YWwgPC9wPjxiciAvPgo8cD4gQSBNb3ZpZSBEaXJlY3RvciBOYW1lIDogRGVuaXMgVmlsbGVuZXV2ZTwvcD48YnIgLz4KPHA%2BIENhc3RpbmcgSW4gTW92aWUgOiBBbXkgQWRhbXMsIEplcmVteSBSZW5uZXIsIEZvcmVzdCBXaGl0YWtlcjwvcD48YnIgLz4KPHA%2BIFJlbGVhc2VkIFllYXIgOiAyMDE2PC9wPjxiciAvPgo8cD4gQ291bnRyeSBGcm9tIDogVVNBPC9wPjxiciAvPgo8cD4gTGFuZ3VhZ2UgVXNlZCA6IEVuZ2xpc2g8L3A%2BPGJyIC8%2BCjxwPiBHZW5yZXMgc2VlbXMgOiBEcmFtYSwgTXlzdGVyeSwgU2NpLUZpIDwvcD4%3D",category:"aG9sbHl3b29kLW1vdmllcy0yMDE2",poster:"aHR0cDovL29ubGluZW1vdmlld2F0Y2hzLnR2L3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDE2LzExL0Fycml2YWwtTW92aWUtUG9zdGVyLmpwZw%3D%3D",rate:"MA%3D%3D",year:"MjAxNg%3D%3D",quality:"TkE%3D",name:"QXJyaXZhbA%3D%3D",genre:"RHJhbWEsIE15c3RlcnksIFNjaS1GaQ%3D%3D",link:"aHR0cDovL29ubGluZW1vdmlld2F0Y2hzLnR2L2Fycml2YWwtMjAxNi1mdWxsLW1vdmllLW9ubGluZS1mcmVlLWhkLw%3D%3D",src:"aHR0cDovLzE2My4xNzIuMjE0LjEwNS95a2dpcGltZWs2MmJpcm1wbmh3Z3J6bHJlMjZkajI1d29veTZ0Y2Y2MzdhM2ZnamRiY3duanc0c3V3aGEvdi5tcDQ%3D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0bWw%3D",status:"MQ%3D%3D" }');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p id='res1'></p>
答案 0 :(得分:2)
因为您将参数mdata
作为字符串传递,而不是作为对象传递。删除之前和之后的单引号,将json正确格式化为数组并且它可以正常工作:
var details = [
{
detail: "PHA%2BTW92aWUgRGV0YWlscyBPZiA6IEFycml2YWwgPC9wPjxiciAvPgo8cD4gQSBNb3ZpZSBEaXJlY3RvciBOYW1lIDogRGVuaXMgVmlsbGVuZXV2ZTwvcD48YnIgLz4KPHA%2BIENhc3RpbmcgSW4gTW92aWUgOiBBbXkgQWRhbXMsIEplcmVteSBSZW5uZXIsIEZvcmVzdCBXaGl0YWtlcjwvcD48YnIgLz4KPHA%2BIFJlbGVhc2VkIFllYXIgOiAyMDE2PC9wPjxiciAvPgo8cD4gQ291bnRyeSBGcm9tIDogVVNBPC9wPjxiciAvPgo8cD4gTGFuZ3VhZ2UgVXNlZCA6IEVuZ2xpc2g8L3A%2BPGJyIC8%2BCjxwPiBHZW5yZXMgc2VlbXMgOiBEcmFtYSwgTXlzdGVyeSwgU2NpLUZpIDwvcD4%3D",
category: "aG9sbHl3b29kLW1vdmllcy0yMDE2",
poster: "aHR0cDovL29ubGluZW1vdmlld2F0Y2hzLnR2L3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDE2LzExL0Fycml2YWwtTW92aWUtUG9zdGVyLmpwZw%3D%3D",
rate: "MA%3D%3D",
year: "MjAxNg%3D%3D",
quality: "TkE%3D",
name: "QXJyaXZhbA%3D%3D",
genre: "RHJhbWEsIE15c3RlcnksIFNjaS1GaQ%3D%3D",
link: "aHR0cDovL29ubGluZW1vdmlld2F0Y2hzLnR2L2Fycml2YWwtMjAxNi1mdWxsLW1vdmllLW9ubGluZS1mcmVlLWhkLw%3D%3D",
src: "aHR0cDovLzE2My4xNzIuMjE0LjEwNS95a2dpcGltZWs2MmJpcm1wbmh3Z3J6bHJlMjZkajI1d29veTZ0Y2Y2MzdhM2ZnamRiY3duanc0c3V3aGEvdi5tcDQ%3D",
playersrc: "aHR0cDovL3B1dGxvYWQudHYvZW1iZWQtdDBpNDZodXplMG5lLmh0bWw%3D",
status: "MQ%3D%3D"
},
{
detail: "PHA%2BTW92aWUgRGV0YWlscyBPZiA6IEFycml2YWwgPC9wPjxiciAvPgo8cD4gQSBNb3ZpZSBEaXJlY3RvciBOYW1lIDogRGVuaXMgVmlsbGVuZXV2ZTwvcD48YnIgLz4KPHA%2BIENhc3RpbmcgSW4gTW92aWUgOiBBbXkgQWRhbXMsIEplcmVteSBSZW5uZXIsIEZvcmVzdCBXaGl0YWtlcjwvcD48YnIgLz4KPHA%2BIFJlbGVhc2VkIFllYXIgOiAyMDE2PC9wPjxiciAvPgo8cD4gQ291bnRyeSBGcm9tIDogVVNBPC9wPjxiciAvPgo8cD4gTGFuZ3VhZ2UgVXNlZCA6IEVuZ2xpc2g8L3A%2BPGJyIC8%2BCjxwPiBHZW5yZXMgc2VlbXMgOiBEcmFtYSwgTXlzdGVyeSwgU2NpLUZpIDwvcD4%3D",
category: "aG9sbHl3b29kLW1vdmllcy0yMDE2",
poster: "aHR0cDovL29ubGluZW1vdmlld2F0Y2hzLnR2L3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDE2LzExL0Fycml2YWwtTW92aWUtUG9zdGVyLmpwZw%3D%3D",
rate: "MA%3D%3D",
year: "MjAxNg%3D%3D",
quality: "TkE%3D",
name: "QXJyaXZhbA%3D%3D",
genre: "RHJhbWEsIE15c3RlcnksIFNjaS1GaQ%3D%3D",
link: "aHR0cDovL29ubGluZW1vdmlld2F0Y2hzLnR2L2Fycml2YWwtMjAxNi1mdWxsLW1vdmllLW9ubGluZS1mcmVlLWhkLw%3D%3D",
src: "aHR0cDovLzE2My4xNzIuMjE0LjEwNS95a2dpcGltZWs2MmJpcm1wbmh3Z3J6bHJlMjZkajI1d29veTZ0Y2Y2MzdhM2ZnamRiY3duanc0c3V3aGEvdi5tcDQ%3D",
playersrc: "aHR0cDovL3B1dGxvYWQudHYvZW1iZWQtdDBpNDZodXplMG5lLmh0bWw%3D",
status: "MQ%3D%3D"
}
];
AData(
'1',
'http://api.techsoul.in/movies/techsoul-update-movies.php?token=777&fun=addmovie',
details
);
编辑:在这篇文章的第一个版本中,我没有看到你的json无效。现在看看我的答案,它应该没有任何错误。另外,请告知您自己有关JSON标准并符合您的需求。