所以我的代碼,我想轉成JSON是以下的jQuery不會把這個變成JSON
var locationData = [];
locationData['lat'] = position.coords.latitude;
locationData['long'] = position.coords.longitude;
locationData['address']['road'] = data['address']['road'];
locationData['address']['suburb'] = data['address']['suburb'];
locationData['address']['city'] = data['address']['city'];
locationData['address']['county'] = data['address']['county'];
locationData['address']['state'] = data['address']['state'];
locationData['address']['postcode'] = data['address']['postcode'];
locationData['address']['country'] = data['address']['country'];
locationData['address']['country_code'] = data['address']['country_code'];
但是當我運行它,它不提醒我,它已經成功
Alert?代碼中沒有提示。嘗試'console.log'的JSON並檢查它是否格式正確。 –
你在這個數組中使用什麼上下文? –