我有一堆在图库中显示的图像。 来自json文件。
每个> object test javascript
let positives = ['yes', 'yeah', 'yep', 'yup', 'yh', 'ya', 'y', 'sure'];
let negatives = ['no', 'nope', 'na', 'nah', 'pass'];
var action = 'undefined';
for (var i = 0; i < args.length; i++) {
if (positives.indexOf(args[i]) !== -1) {
action = 'yes'
break;
} else if (negatives.indexOf(args[i]) !== -1){
action = 'no'
break;
} else {
}
}
return action;
< object
// In the topic/main section
+ [*] you [*]
- Oh, so we're talking about me now?
+ *
% oh so we are talking about me now
* <call>test <lowercase></call> == no => Whatever...
* <call>test <lowercase></call> == yes => This should be fun.{topic=myself}
* <call>test <lowercase></call> == undefined => So, back to the matter at hand...
- So, back to the matter at hand...
都有一个ID,
在单击时,带有ID的jquery脚本会被执行
并通过ajax将其传递回php脚本,该脚本应从json中删除该图像。
这是我的代码:
<img>
我遇到的问题是 我不能用这个
function deletebtn(){
$(".delete-button").click(function(event) {
var deleteme = event.target.id;
$("#"+ deleteme).remove();
var jsondelete = "http://localhost/wordpress/api/json/gallery.json";
$.getJSON( jsondelete, {
format: "json"
})
.done(function( data ) {
delete data.images.+deleteme;
var data = JSON.stringify(data);
$( "#json_delete" ).html(data);
var brick = $( "#json_delete" ).html();
$.ajax({
url: 'http://localhost/gallery/deletejson.php',
method: 'POST',
data: {
"json": brick,
},
success: function(result) {
console.log("SAVED JSON");
},
error: function(result) {
alert("DID NOT SAVE JSON");
}
});
});
});
}
如果将此功能转换为
delete data.images.+deleteme;
这有效。 我怎么试图通过var $ deleteme
delete data.images.img_177;
如果您使用警报或控制台日志,则为
var $deleteme = event.target.id;
我想念什么吗?