var idlist = []; var datalist = {}; if (callback) { var callback; } $(function(){ $.ajax({ url: 'json.php?area=1', type: 'get', dataType: 'json', success: function(data){ $(data).each(function(){ lat = parseDouble(this.latitude); lng = parseDouble(this.longitude); if (!isNaN(lat) && !isNaN(lng)) { this.latitude = lat; this.longitude = lng; idlist.push(this.id); datalist[this.id] = this; } }); if (is("Function", callback)) { callback(); } }, error: function(XMLHttpRequest, textStatus, errorThrown, data) { //エラーメッセージの表示 //alert('getJsonError : ' + XMLHttpRequest + ":" + textStatus + ":" + errorThrown); } }); }); function parseDouble(value){ if (typeof value == "string" && value.length) { var ary = value.match(/^-?\d+\.?\d*/); if (ary && ary.length) { value = ary[0]; } } return !isNaN(parseInt(value)) ? value * 1 : NaN; } function is(type, obj) { var className = Object.prototype.toString.call(obj).slice(8, -1); return obj !== undefined && obj !== null && className === type; }