jquery - Deferred.done callback not working in the done function -


i have been trying make work couple of days now, last attempt.

and apologies posting different questions similar objective.

i tried figure out best way.

here thing; have data in page want use in initialize function.

one member here suggested use deferred.done.

it partially worked. data in other page loaded , can displayed if have alert(mapdata); in initialize function.

but when try use data in initialize function actual work, mapdata.users undefined error.

i dont because appears fine when loaded in alert box.

please suggest!

    $(function checkinmap() {         $.when($.ajax({             type: "get",             url: "content/home/index.cs.asp?process=viewcheckinmap"         })).done(      function initialize(data) {             var mapdata = data;             var center = new google.maps.latlng(48.404840395764175, 2.6845264434814453);             var map = new google.maps.map(document.getelementbyid('checkinmap'), {               zoom: 2,               center: center,               maptypeid: google.maps.maptypeid.roadmap,               maxzoom: 4             });             var markers = [];             (var = 0; < mapdata.users.length; i++) {               var location = mapdata.users[i];               var latlng = new google.maps.latlng(location.latitude,                   location.longitude);               var marker = new google.maps.marker({                 position: latlng               });               markers.push(marker);             }             var markercluster = new markerclusterer(map, markers);         });     }); 

this data need use in initialize function.

{   "users": [     {       "latitude": "48.405163",       "longitude": "2.684659"     },     {       "latitude": "43.7347242529278",       "longitude": "7.42198348045349"     }   ] }; 

you haven't specified datatype: 'json' in $.ajax() call; results in data being raw text json response, , not decoded object.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -