Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
191
rated 0 times [  195] [ 4]  / answers: 1 / hits: 19912  / 11 Years ago, thu, june 13, 2013, 12:00:00

I would like to store json file to my amazon s3 and then retrieve it with ajax request. Unfortunately it seems s3 does not allow content-type application/json....



I should save my file as text/plain and then add header with php?


More From » json

 Answers
3

I have found the problem. I was parsing the json in the wrong way.



$.ajax({
url:https://s3.amazonaws.com/myBucket/myfile.json,
type:GET,
success:function(data) {
console.log(data.property)
}
})


Instead this works:



$.ajax({
url:https://s3.amazonaws.com/myBucket/myfile.json,
type:GET,
success:function(data) {
var obj = jQuery.parseJSON(data);
if(typeof obj =='object'){
console.log(obj.property)
}
}
})

[#77639] Wednesday, June 12, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
analiseb

Total Points: 252
Total Questions: 96
Total Answers: 106

Location: Singapore
Member since Sat, Jul 25, 2020
4 Years ago
analiseb questions
;