2014-02-13 220 views
0
$(document).ready(function() { 
    var oOpenOrders = new Array(); 
    $('#btn').click(function() { 
     $.ajax({ 
      type: 'GET', 
      url: 'http://192.168.19.22/test.php', 
      contentType: "application/json; charset=utf-8", 
      dataType: 'json', 
      success: function (data) { 
       debugger; 
       for(var i=0; i<data.length; i++){ 
        alert(typeof(data.id)); 
        oOpenOrders.push(data); 
       } 
       var obj = jQuery.parseJSON(data); 
       debugger; 

我使用,並希望它解析此代碼段(想用緯度,經度)甚至data.length說正確長度4以下JSON,以下JSON是從Ajax調用來:的Javascript JSON對象解析

[{"id":"3037","latitude":"28.617422000","longitude":"77.381180000"}, 
{"id":"3036","latitude":"28.617422000","longitude":"77.381180000"}, 
{"id":"3035","latitude":"28.617422000","longitude":"77.381180000"}, 
{"id":"3034","latitude":"28.617422000","longitude":"77.381180000"}] 

有什麼想法嗎?

+1

和問題了嗎? – Sarath

+0

我想LAT保存,長在一個全局數組 –

+0

'警報(data.id);'是警報未定義,並且這其中,i是stucked –

回答

1

試試這個

alert(typeof data[i].id);