PHP ver gevorderde |
|
Hey,
Ik probeer deze JSON string:
{"memoryText":["256 MB","512 MB","1024 MB","2048 MB","4096 MB","8192 MB","16384 MB"],"memoryPrice":["1.00","2.00","4.00","5.50","10.00","20.00","35.00"],"harddiskText":["5 GB","10 GB","25 GB","50 GB","100 GB","250 GB","500 GB","1 TB"],"harddiskPrice":["0.50","1.00","2.00","4.00","7.50","15.00","27.50","40.00"]}
Om te zetten naar:
var memoryText = new Array("256 MB", "512 MB", "1024 MB", "2048 MB", "4096 MB", "8192 MB", "16384 MB");
var memoryPrice = new Array("1.00", "2.00", "4.00", "5.50", "10.00", "20.00", "35.00");
var harddiskText = new Array("5 GB", "10 GB", "25 GB", "50 GB", "100 GB", "250 GB", "500 GB", "1 TB");
var harddiskPrice = new Array("0.50", "1.00", "2.00", "4.00", "7.50", "15.00", "27.50", "40.00");
mbv jQuery probeer ik dit als volgt:
$.getJSON("getJSON.php",
function(data){
var memoryText = eval(data.memoryText);
var memoryPrice = eval(data.memoryPrice);
var harddiskText = eval(data.harddiskText);
var harddiskPrice = eval(data.harddiskPrice);
}
);
dit gaat niet goed want zodra ik hierbuiten alert(memoryText[1]); doe krijg ik niks.
Heeft iemand enig idee wat er misgaat? Heb ook al new Array(data.memoryText); geprobeerd maar zonder resultaat.
Begin er een beetje gek van te worden..
Ikki.
|