Javascript 如何获取JSON字符串的一部分?
警报告诉我: {“消息”:“成功”,“文件ID”:399} 我想获取fileID值,在本例中为399。 谢谢。很简单Javascript 如何获取JSON字符串的一部分?,javascript,jquery,json,Javascript,Jquery,Json,警报告诉我: {“消息”:“成功”,“文件ID”:399} 我想获取fileID值,在本例中为399。 谢谢。很简单 this.on('success', function(file, responseText) { var theID = JSON.stringify(responseText); alert(theID); window.location.href =
this.on('success', function(file, responseText) {
var theID = JSON.stringify(responseText);
alert(theID);
window.location.href = ('want to put something here');
});
因为responseText已经是JSON了
this.on('success', function(file, responseText) {
var theID = JSON.stringify(responseText);
alert(theID);
window.location.href = ('want to put something here');
});
window.location.href = responseText.fileID;
因为responseText已经是JSON,所以将执行此操作。如果responseText已经是JSON格式,则:
window.location.href = responseText.fileID;
this.on('success', function(file, responseText) {
var theID = JSON.stringify(responseText);
alert(theID);
if(responseText.fileID == 399) {
// Do something
}
window.location.href = ('want to put something here');
});
如果是字符串格式,则首先解析它:
responseText.fileID
如果responseText已为JSON格式,则:
this.on('success', function(file, responseText) {
var theID = JSON.stringify(responseText);
alert(theID);
if(responseText.fileID == 399) {
// Do something
}
window.location.href = ('want to put something here');
});
如果是字符串格式,则首先解析它:
responseText.fileID
responseText.fileID
If是JSON
对象而不是text
responseText.fileID
If是JSON
对象而不是text