解析 JSON-RPC 响应 jquery 未定义
Parsing JSON-RPC response with jquery undefined
简而言之,我需要从下面的json字符串
中获取文件名
{"jsonrpc" : "2.0", "result" : {"cleanFileName": "1430648069-img003.jpg"}, "id" : "id"}
代码如下:
init: {
// FileUploaded is called when a file has been uploaded, and contains all info about the file
FileUploaded: function(up, file, info) {
var obj = JSON.parse(info.response);
alert(obj.cleanFileName);
}
}
我想我可以使用下面的方法来获取 cleanFileName
var obj = JSON.parse(info.response);
alert(obj.cleanFileName);
这只是给了我一个未定义的警报,我错过了什么?
alert (obj['result']['cleanFileName']);
简而言之,我需要从下面的json字符串
中获取文件名{"jsonrpc" : "2.0", "result" : {"cleanFileName": "1430648069-img003.jpg"}, "id" : "id"}
代码如下:
init: {
// FileUploaded is called when a file has been uploaded, and contains all info about the file
FileUploaded: function(up, file, info) {
var obj = JSON.parse(info.response);
alert(obj.cleanFileName);
}
}
我想我可以使用下面的方法来获取 cleanFileName
var obj = JSON.parse(info.response);
alert(obj.cleanFileName);
这只是给了我一个未定义的警报,我错过了什么?
alert (obj['result']['cleanFileName']);