Récupérer les données json d'une api
bonjour j'essaie de recuperer des données de mon api à partir d'ajax mais ça me signale une erreur
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| <script>
$(function (){
$.ajax({
type : 'GET',
dataType: 'jsonp',
crossOrigin: true,
url : 'http://127.0.0.1:5000/star',
headers: {
'Access-Control-Allow-Origin': ' ',
'Content-Type': 'application/json'
},
success: function(data){
console.log('success', data.result);
}
});
});
</script> |
voici le code et quand je verifie ma console il me donne cette erreur :
Citation:
"SyntaxError: unexpected token: ':'"
voici les donnees de mon api
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| {
"result": [
{
"Count_customer": 16,
"Quantity": 224,
"StockCode": "10002",
"month": 12,
"year": 2010
},
{
"Count_customer": 18,
"Quantity": 337,
"StockCode": "10002",
"month": 1,
"year": 2011
},
{
"Count_customer": 5,
"Quantity": 50,
"StockCode": "10002",
"month": 2,
"year": 2011
},
{
"Count_customer": 5,
"Quantity": 23,
"StockCode": "10002",
"month": 3,
"year": 2011
}, ... |