0
A
Répondre
1
Deux problèmes:
- Vous devez eval la chaîne JSON pour obtenir un objet.
- La valeur d'arrière-plan est des guillemets manquants.
Il fonctionne comme ceci:
var gib = eval("({background:'default.jpg'})");
alert(gib.background)
0
Mauvaise syntaxe dans json.
var gib={background:"default.jpg"};
alert(gib.background);
0
Vous êtes actuellement juste instancier une chaîne, plutôt qu'un objet JSON - JSON objets ne sont pas entourés de guillemets.
est ici la version fixe:
var gib = { background : "default.jpg "};
alert(gib.background)
0
Vous devez JSON pour être valide comme celui-ci var GIB = { "fond": "default.jpg"}
Alors oui Parse en objet premier si vous utilisez jquery jQuery.parseJSON ("{background: default.jpg}"); alerte (gib.background)
Questions connexes
- 1. Problème de rappel JSON
- 2. Problème lors de l'analyse JSON
- 3. PHP JSON. Problème de confusion
- 4. Une solution soignée pour l'utilisation de données JSON statiques
- 5. javascript json - problème de décodage ajax json array de php
- 6. contrainte Problème/solution dans sqlServer
- 7. Problème JSON onFailure
- 8. jQuery JSON Problème
- 9. JSON Mootools problème Array
- 10. tri objet JSON Problème
- 11. problème avec JSON
- 12. jquery problème JSON
- 13. problème JSON dans flickr
- 14. JSON et problème Mysql
- 15. VS2003: problème avec une solution de construction
- 16. Problème de distribution d'annonces: une solution optimale?
- 17. C de solution élégante à partitionner problème
- 18. Problème lors de l'envoi de données JSON
- 19. Problème de codage de caractères json
- 20. problème décoder une chaîne JSON contenant « » »
- 21. Problème avec JSON et jQuery
- 22. problème jQuery AJAX PHP JSON
- 23. problème avec JSON dans Grails
- 24. problème désérialisation JSON avec JSON.NET
- 25. Problème d'affichage du fichier json
- 26. jQuery, JSON et problème Apache
- 27. FullCalendar JSON Source de l'événement Problème
- 28. ASP.NET (C#) problème de données JSON jQuery
- 29. Xml à JSon, problème de caractère
- 30. Problème de flux IPhone xcode JSON
D'où vient le JSON? –
il vient de la base de données – XMen