En effet, dès que les données retournées atteignent un certain nombre de
Ko, je vois correctement la réponse dans Firebug (en-tête "Réponse"),
correctement formaté en JSON, mais ma fonction de callback n'est pas
appelée :-(
En revanche, tout se passe à merveille quand la réponse est plus petite.
J'ai cherché mon problème sur plein de forums, mais sans trouver mon
problème.
En effet, dès que les données retournées atteignent un certain nombre de
Ko, je vois correctement la réponse dans Firebug (en-tête "Réponse"),
correctement formaté en JSON, mais ma fonction de callback n'est pas
appelée :-(
En revanche, tout se passe à merveille quand la réponse est plus petite.
J'ai cherché mon problème sur plein de forums, mais sans trouver mon
problème.
En effet, dès que les données retournées atteignent un certain nombre de
Ko, je vois correctement la réponse dans Firebug (en-tête "Réponse"),
correctement formaté en JSON, mais ma fonction de callback n'est pas
appelée :-(
En revanche, tout se passe à merveille quand la réponse est plus petite.
J'ai cherché mon problème sur plein de forums, mais sans trouver mon
problème.
Groquik a écrit :En effet, dès que les données retournées atteignent un certain nombre
de Ko, je vois correctement la réponse dans Firebug (en-tête
"Réponse"), correctement formaté en JSON, mais ma fonction de callback
n'est pas appelée :-(
Quel est le code ?
En revanche, tout se passe à merveille quand la réponse est plus
petite. J'ai cherché mon problème sur plein de forums, mais sans
trouver mon problème.
Il y a des limites à tout :) Mais le problème peut venir de tellement
d'endroits qu'il faut du code. Et surtout, il faut qu'on ai les données
qui aboutissent au problème.
Groquik a écrit :
En effet, dès que les données retournées atteignent un certain nombre
de Ko, je vois correctement la réponse dans Firebug (en-tête
"Réponse"), correctement formaté en JSON, mais ma fonction de callback
n'est pas appelée :-(
Quel est le code ?
En revanche, tout se passe à merveille quand la réponse est plus
petite. J'ai cherché mon problème sur plein de forums, mais sans
trouver mon problème.
Il y a des limites à tout :) Mais le problème peut venir de tellement
d'endroits qu'il faut du code. Et surtout, il faut qu'on ai les données
qui aboutissent au problème.
Groquik a écrit :En effet, dès que les données retournées atteignent un certain nombre
de Ko, je vois correctement la réponse dans Firebug (en-tête
"Réponse"), correctement formaté en JSON, mais ma fonction de callback
n'est pas appelée :-(
Quel est le code ?
En revanche, tout se passe à merveille quand la réponse est plus
petite. J'ai cherché mon problème sur plein de forums, mais sans
trouver mon problème.
Il y a des limites à tout :) Mais le problème peut venir de tellement
d'endroits qu'il faut du code. Et surtout, il faut qu'on ai les données
qui aboutissent au problème.
Hello !
Je viens de constater un problème plutôt embarrassant :
J'utilise la méthode getJSON() de JQuery, qui fonctionne bien... sauf
quand le JSON retourné est trop gros !
En effet, dès que les données retournées atteignent un certain nombre de
Ko, je vois correctement la réponse dans Firebug (en-tête "Réponse"),
correctement formaté en JSON, mais ma fonction de callback n'est pas
appelée :-(
En revanche, tout se passe à merveille quand la réponse est plus petite.
J'ai cherché mon problème sur plein de forums, mais sans trouver mon
problème.
Quelqu'un peut-il m'apporter ses lumières ?
Hello !
Je viens de constater un problème plutôt embarrassant :
J'utilise la méthode getJSON() de JQuery, qui fonctionne bien... sauf
quand le JSON retourné est trop gros !
En effet, dès que les données retournées atteignent un certain nombre de
Ko, je vois correctement la réponse dans Firebug (en-tête "Réponse"),
correctement formaté en JSON, mais ma fonction de callback n'est pas
appelée :-(
En revanche, tout se passe à merveille quand la réponse est plus petite.
J'ai cherché mon problème sur plein de forums, mais sans trouver mon
problème.
Quelqu'un peut-il m'apporter ses lumières ?
Hello !
Je viens de constater un problème plutôt embarrassant :
J'utilise la méthode getJSON() de JQuery, qui fonctionne bien... sauf
quand le JSON retourné est trop gros !
En effet, dès que les données retournées atteignent un certain nombre de
Ko, je vois correctement la réponse dans Firebug (en-tête "Réponse"),
correctement formaté en JSON, mais ma fonction de callback n'est pas
appelée :-(
En revanche, tout se passe à merveille quand la réponse est plus petite.
J'ai cherché mon problème sur plein de forums, mais sans trouver mon
problème.
Quelqu'un peut-il m'apporter ses lumières ?
Bon en fait ça n'avait rien à voir avec la taille du JSON retourné...
C'était en fait à cause de quelques guillemets qui apparaissent dans
certains résultats, et qui causaient le problème.
J'ai donc remplacé les guillemets par *"* (grâce à une fonction en
PHP), et maintenant ça fonctionne nickel.
@ bientôt
Bon en fait ça n'avait rien à voir avec la taille du JSON retourné...
C'était en fait à cause de quelques guillemets qui apparaissent dans
certains résultats, et qui causaient le problème.
J'ai donc remplacé les guillemets par *"* (grâce à une fonction en
PHP), et maintenant ça fonctionne nickel.
@ bientôt
Bon en fait ça n'avait rien à voir avec la taille du JSON retourné...
C'était en fait à cause de quelques guillemets qui apparaissent dans
certains résultats, et qui causaient le problème.
J'ai donc remplacé les guillemets par *"* (grâce à une fonction en
PHP), et maintenant ça fonctionne nickel.
@ bientôt
Je viens de constater un problème plutôt embarrassant :
J'utilise la méthode getJSON() de JQuery, qui fonctionne bien... sauf
quand le JSON retourné est trop gros !
Je viens de constater un problème plutôt embarrassant :
J'utilise la méthode getJSON() de JQuery, qui fonctionne bien... sauf
quand le JSON retourné est trop gros !
Je viens de constater un problème plutôt embarrassant :
J'utilise la méthode getJSON() de JQuery, qui fonctionne bien... sauf
quand le JSON retourné est trop gros !
Je viens de constater un problème plutôt embarrassant :
J'utilise la méthode getJSON() de JQuery, qui fonctionne bien... sauf
quand le JSON retourné est trop gros !
Ensuite, attention le code suivant:
var x = []
x[0] = 10;
x[20000] = 10;
Te donne un tableau serialisé enorme puisqu'il va considérer que x[1], x[2],
... x[19999] vallent tous null.
donc parfois jsute une tite modif permet de te réduire considérablement la
taille de tes données serialisées!
Je viens de constater un problème plutôt embarrassant :
J'utilise la méthode getJSON() de JQuery, qui fonctionne bien... sauf
quand le JSON retourné est trop gros !
Ensuite, attention le code suivant:
var x = []
x[0] = 10;
x[20000] = 10;
Te donne un tableau serialisé enorme puisqu'il va considérer que x[1], x[2],
... x[19999] vallent tous null.
donc parfois jsute une tite modif permet de te réduire considérablement la
taille de tes données serialisées!
Je viens de constater un problème plutôt embarrassant :
J'utilise la méthode getJSON() de JQuery, qui fonctionne bien... sauf
quand le JSON retourné est trop gros !
Ensuite, attention le code suivant:
var x = []
x[0] = 10;
x[20000] = 10;
Te donne un tableau serialisé enorme puisqu'il va considérer que x[1], x[2],
... x[19999] vallent tous null.
donc parfois jsute une tite modif permet de te réduire considérablement la
taille de tes données serialisées!
Ensuite, attention le code suivant:
var x = []
x[] = 10;
x[20000] = 10;
Te donne un tableau serialisé enorme puisqu'il va considérer que x[1],
x[2], ... x[19999] vallent tous null.
Ensuite, attention le code suivant:
var x = []
x[] = 10;
x[20000] = 10;
Te donne un tableau serialisé enorme puisqu'il va considérer que x[1],
x[2], ... x[19999] vallent tous null.
Ensuite, attention le code suivant:
var x = []
x[] = 10;
x[20000] = 10;
Te donne un tableau serialisé enorme puisqu'il va considérer que x[1],
x[2], ... x[19999] vallent tous null.
Bonjour,
est-ce que le fait d'écrire:
x[ 20000+"" ] = 10;
ou:
x[ new String(20000) ] = 10;
(ou quelque chose d'approchant)
...résoud ce problème, SVP ?
Bonjour,
est-ce que le fait d'écrire:
x[ 20000+"" ] = 10;
ou:
x[ new String(20000) ] = 10;
(ou quelque chose d'approchant)
...résoud ce problème, SVP ?
Bonjour,
est-ce que le fait d'écrire:
x[ 20000+"" ] = 10;
ou:
x[ new String(20000) ] = 10;
(ou quelque chose d'approchant)
...résoud ce problème, SVP ?
Voici un bout de code éclairant :
<script>
var tab1 = []; // tableau indexé
tab1[1000] = "test"; // dim dynamique selon index le + élevé
console.log(tab1.length); // = 1001
tab1["2000"] = "test"; // redim dynamique, index transtypé
console.log(tab1.length); // = 2001
var tab2 = {}; // objet = tableau associatif
tab2["1000"] = "test"; // dim dynamique selon nb membres
// calcul du nb de membres
var tab2Length = 0;
for (var prop in tab2) {
tab2Length ++;
}
console.log(tab2Length); // = 1
</script>
15.4.5.1 [[Put]] (P, V)
Array objects use a variation of the [[Put]] method used for other native ECMAScript objects
(8.6.2.2).
Assume A is an Array object and P is a string.
When the [[Put]] method of A is called with property P and value V, the following steps are taken:
1. Call the [[CanPut]] method of A with name P.
2. If Result(1) is false, return.
3. If A doesn’t have a property with name P, go to step 7.
4. If P is "length", go to step 12.
5. Set the value of property P of A to V.
6. Go to step 8.
7. Create a property with name P, set its value to V and give it empty attributes.
8. If P is not an array index, return.
9. If ToUint32(P) is less than the value of the length property of A, then return.
10. Change (or set) the value of the length property of A to ToUint32(P)+1.
11. Return.
12. Compute ToUint32(V).
13. If Result(12) is not equal to ToNumber(V), throw a RangeError exception.
14. For every integer k that is less than the value of the length property of A but not less than
Result(12), if A itself has a property (not an inherited property) named ToString(k), then delete
that property.
15. Set the value of property P of A to Result(12).
16. Return.
Voici un bout de code éclairant :
<script>
var tab1 = []; // tableau indexé
tab1[1000] = "test"; // dim dynamique selon index le + élevé
console.log(tab1.length); // = 1001
tab1["2000"] = "test"; // redim dynamique, index transtypé
console.log(tab1.length); // = 2001
var tab2 = {}; // objet = tableau associatif
tab2["1000"] = "test"; // dim dynamique selon nb membres
// calcul du nb de membres
var tab2Length = 0;
for (var prop in tab2) {
tab2Length ++;
}
console.log(tab2Length); // = 1
</script>
15.4.5.1 [[Put]] (P, V)
Array objects use a variation of the [[Put]] method used for other native ECMAScript objects
(8.6.2.2).
Assume A is an Array object and P is a string.
When the [[Put]] method of A is called with property P and value V, the following steps are taken:
1. Call the [[CanPut]] method of A with name P.
2. If Result(1) is false, return.
3. If A doesn’t have a property with name P, go to step 7.
4. If P is "length", go to step 12.
5. Set the value of property P of A to V.
6. Go to step 8.
7. Create a property with name P, set its value to V and give it empty attributes.
8. If P is not an array index, return.
9. If ToUint32(P) is less than the value of the length property of A, then return.
10. Change (or set) the value of the length property of A to ToUint32(P)+1.
11. Return.
12. Compute ToUint32(V).
13. If Result(12) is not equal to ToNumber(V), throw a RangeError exception.
14. For every integer k that is less than the value of the length property of A but not less than
Result(12), if A itself has a property (not an inherited property) named ToString(k), then delete
that property.
15. Set the value of property P of A to Result(12).
16. Return.
Voici un bout de code éclairant :
<script>
var tab1 = []; // tableau indexé
tab1[1000] = "test"; // dim dynamique selon index le + élevé
console.log(tab1.length); // = 1001
tab1["2000"] = "test"; // redim dynamique, index transtypé
console.log(tab1.length); // = 2001
var tab2 = {}; // objet = tableau associatif
tab2["1000"] = "test"; // dim dynamique selon nb membres
// calcul du nb de membres
var tab2Length = 0;
for (var prop in tab2) {
tab2Length ++;
}
console.log(tab2Length); // = 1
</script>
15.4.5.1 [[Put]] (P, V)
Array objects use a variation of the [[Put]] method used for other native ECMAScript objects
(8.6.2.2).
Assume A is an Array object and P is a string.
When the [[Put]] method of A is called with property P and value V, the following steps are taken:
1. Call the [[CanPut]] method of A with name P.
2. If Result(1) is false, return.
3. If A doesn’t have a property with name P, go to step 7.
4. If P is "length", go to step 12.
5. Set the value of property P of A to V.
6. Go to step 8.
7. Create a property with name P, set its value to V and give it empty attributes.
8. If P is not an array index, return.
9. If ToUint32(P) is less than the value of the length property of A, then return.
10. Change (or set) the value of the length property of A to ToUint32(P)+1.
11. Return.
12. Compute ToUint32(V).
13. If Result(12) is not equal to ToNumber(V), throw a RangeError exception.
14. For every integer k that is less than the value of the length property of A but not less than
Result(12), if A itself has a property (not an inherited property) named ToString(k), then delete
that property.
15. Set the value of property P of A to Result(12).
16. Return.
Le 24/03/2010 18:51, Pascal a écrit :Voici un bout de code éclairant :
<script>
var tab1 = []; // tableau indexé
tab1[1000] = "test"; // dim dynamique selon index le + élevé
console.log(tab1.length); // = 1001
tab1["2000"] = "test"; // redim dynamique, index transtypé
console.log(tab1.length); // = 2001
var tab2 = {}; // objet = tableau associatif
tab2["1000"] = "test"; // dim dynamique selon nb membres
// calcul du nb de membres
var tab2Length = 0;
for (var prop in tab2) {
tab2Length ++;
}
console.log(tab2Length); // = 1
</script>
Hahahaha ! Tu m'avais fait peur ! Le fait que tu te bases sur la
propriété 'length' pour estimer la taille réelle de l'objet est
éclairant en effet, du moins si le code ci-dessus est du JavaScript
(je ne connais pas les trucs cités dans le titre, JQuery et JSON, et
s'ils utilisent un interpréteur autre que JavaScript ma remarque ne
vaudra rien).
Voyons ce que dit la norme.
http://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf
<cit.>15.4.5.1 [[Put]] (P, V)
Array objects use a variation of the [[Put]] method used for other native ECMAScript objects
(8.6.2.2).
Assume A is an Array object and P is a string.
When the [[Put]] method of A is called with property P and value V, the following steps are taken:
1. Call the [[CanPut]] method of A with name P.
2. If Result(1) is false, return.
3. If A doesn’t have a property with name P, go to step 7.
4. If P is "length", go to step 12.
5. Set the value of property P of A to V.
6. Go to step 8.
7. Create a property with name P, set its value to V and give it empty attributes.
8. If P is not an array index, return.
9. If ToUint32(P) is less than the value of the length property of A, then return.
10. Change (or set) the value of the length property of A to ToUint32(P)+1.
11. Return.
12. Compute ToUint32(V).
13. If Result(12) is not equal to ToNumber(V), throw a RangeError exception.
14. For every integer k that is less than the value of the length property of A but not less than
Result(12), if A itself has a property (not an inherited property) named ToString(k), then delete
that property.
15. Set the value of property P of A to Result(12).
16. Return.
</cit.>
En gros, cela dit ceci :
1) tab1["machin"] = "truc" crée une propriété de nom "machin" et de
valeur "truc" et c'est tout.
2) tab1[1000] = "truc" crée une propriété de nom "1000" et de valeur
"truc", *et* passe la valeur de la propriété "length" à 1001 (sauf bien
sûr si elle était déjà supérieure à 1000).
3) tab1["length"] = 10 efface toutes les propriétés dont la valeur
numérique est supérieure ou égale à 10 et inférieure à la propriété
"length", puis passe la valeur de la propriété "length" à 10.
Nulle part il n'est question de créer 999 éléments nuls quand tu
ajoutes l'élément indexé par 1000 ! Et donc, pour calculer le nombre
réel d'éléments de tab1, tu dois faire comme pour tab2 : une boucle
« for (var prop in tab1) ».
Note au passage que tab1[1000] ou tab1["1000"] crée exactement la même
propriété, dont le nom est "1000" et non pas 1000.
Le 24/03/2010 18:51, Pascal a écrit :
Voici un bout de code éclairant :
<script>
var tab1 = []; // tableau indexé
tab1[1000] = "test"; // dim dynamique selon index le + élevé
console.log(tab1.length); // = 1001
tab1["2000"] = "test"; // redim dynamique, index transtypé
console.log(tab1.length); // = 2001
var tab2 = {}; // objet = tableau associatif
tab2["1000"] = "test"; // dim dynamique selon nb membres
// calcul du nb de membres
var tab2Length = 0;
for (var prop in tab2) {
tab2Length ++;
}
console.log(tab2Length); // = 1
</script>
Hahahaha ! Tu m'avais fait peur ! Le fait que tu te bases sur la
propriété 'length' pour estimer la taille réelle de l'objet est
éclairant en effet, du moins si le code ci-dessus est du JavaScript
(je ne connais pas les trucs cités dans le titre, JQuery et JSON, et
s'ils utilisent un interpréteur autre que JavaScript ma remarque ne
vaudra rien).
Voyons ce que dit la norme.
http://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf
<cit.>
15.4.5.1 [[Put]] (P, V)
Array objects use a variation of the [[Put]] method used for other native ECMAScript objects
(8.6.2.2).
Assume A is an Array object and P is a string.
When the [[Put]] method of A is called with property P and value V, the following steps are taken:
1. Call the [[CanPut]] method of A with name P.
2. If Result(1) is false, return.
3. If A doesn’t have a property with name P, go to step 7.
4. If P is "length", go to step 12.
5. Set the value of property P of A to V.
6. Go to step 8.
7. Create a property with name P, set its value to V and give it empty attributes.
8. If P is not an array index, return.
9. If ToUint32(P) is less than the value of the length property of A, then return.
10. Change (or set) the value of the length property of A to ToUint32(P)+1.
11. Return.
12. Compute ToUint32(V).
13. If Result(12) is not equal to ToNumber(V), throw a RangeError exception.
14. For every integer k that is less than the value of the length property of A but not less than
Result(12), if A itself has a property (not an inherited property) named ToString(k), then delete
that property.
15. Set the value of property P of A to Result(12).
16. Return.
</cit.>
En gros, cela dit ceci :
1) tab1["machin"] = "truc" crée une propriété de nom "machin" et de
valeur "truc" et c'est tout.
2) tab1[1000] = "truc" crée une propriété de nom "1000" et de valeur
"truc", *et* passe la valeur de la propriété "length" à 1001 (sauf bien
sûr si elle était déjà supérieure à 1000).
3) tab1["length"] = 10 efface toutes les propriétés dont la valeur
numérique est supérieure ou égale à 10 et inférieure à la propriété
"length", puis passe la valeur de la propriété "length" à 10.
Nulle part il n'est question de créer 999 éléments nuls quand tu
ajoutes l'élément indexé par 1000 ! Et donc, pour calculer le nombre
réel d'éléments de tab1, tu dois faire comme pour tab2 : une boucle
« for (var prop in tab1) ».
Note au passage que tab1[1000] ou tab1["1000"] crée exactement la même
propriété, dont le nom est "1000" et non pas 1000.
Le 24/03/2010 18:51, Pascal a écrit :Voici un bout de code éclairant :
<script>
var tab1 = []; // tableau indexé
tab1[1000] = "test"; // dim dynamique selon index le + élevé
console.log(tab1.length); // = 1001
tab1["2000"] = "test"; // redim dynamique, index transtypé
console.log(tab1.length); // = 2001
var tab2 = {}; // objet = tableau associatif
tab2["1000"] = "test"; // dim dynamique selon nb membres
// calcul du nb de membres
var tab2Length = 0;
for (var prop in tab2) {
tab2Length ++;
}
console.log(tab2Length); // = 1
</script>
Hahahaha ! Tu m'avais fait peur ! Le fait que tu te bases sur la
propriété 'length' pour estimer la taille réelle de l'objet est
éclairant en effet, du moins si le code ci-dessus est du JavaScript
(je ne connais pas les trucs cités dans le titre, JQuery et JSON, et
s'ils utilisent un interpréteur autre que JavaScript ma remarque ne
vaudra rien).
Voyons ce que dit la norme.
http://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf
<cit.>15.4.5.1 [[Put]] (P, V)
Array objects use a variation of the [[Put]] method used for other native ECMAScript objects
(8.6.2.2).
Assume A is an Array object and P is a string.
When the [[Put]] method of A is called with property P and value V, the following steps are taken:
1. Call the [[CanPut]] method of A with name P.
2. If Result(1) is false, return.
3. If A doesn’t have a property with name P, go to step 7.
4. If P is "length", go to step 12.
5. Set the value of property P of A to V.
6. Go to step 8.
7. Create a property with name P, set its value to V and give it empty attributes.
8. If P is not an array index, return.
9. If ToUint32(P) is less than the value of the length property of A, then return.
10. Change (or set) the value of the length property of A to ToUint32(P)+1.
11. Return.
12. Compute ToUint32(V).
13. If Result(12) is not equal to ToNumber(V), throw a RangeError exception.
14. For every integer k that is less than the value of the length property of A but not less than
Result(12), if A itself has a property (not an inherited property) named ToString(k), then delete
that property.
15. Set the value of property P of A to Result(12).
16. Return.
</cit.>
En gros, cela dit ceci :
1) tab1["machin"] = "truc" crée une propriété de nom "machin" et de
valeur "truc" et c'est tout.
2) tab1[1000] = "truc" crée une propriété de nom "1000" et de valeur
"truc", *et* passe la valeur de la propriété "length" à 1001 (sauf bien
sûr si elle était déjà supérieure à 1000).
3) tab1["length"] = 10 efface toutes les propriétés dont la valeur
numérique est supérieure ou égale à 10 et inférieure à la propriété
"length", puis passe la valeur de la propriété "length" à 10.
Nulle part il n'est question de créer 999 éléments nuls quand tu
ajoutes l'élément indexé par 1000 ! Et donc, pour calculer le nombre
réel d'éléments de tab1, tu dois faire comme pour tab2 : une boucle
« for (var prop in tab1) ».
Note au passage que tab1[1000] ou tab1["1000"] crée exactement la même
propriété, dont le nom est "1000" et non pas 1000.