a single call getjson, works fine...
<div class="col-sm-3 col-xs-12" > <label for="pickers" >picker</label> <select name="picker" id="selectpicker" class="form-control" ></select> <label for="grinners" >grinner</label> <select name="grinner" id="selectgrinner" class="form-control" ></select> </div> <script> $( document ).ready( function() { //pickers $.getjson( '/people.php', { get:'pickers' }, function( p ){ var poptions = ''; ( var pi=0; pi<=k['data'].length; pi++ ) { poptions += '<option value="' + p['data'][pi][0] + '">' + p['data'][pi][1] + ' (' + p['data'][pi][2] + ')</option>'; } $( '#selectpicker' ).html( poptions ); }); }); </script>
however - when add call, breaks both of them call, , response, fine, json object being returned, ui not populating selects...
the above works, if add (below) breaks both selects... i've named vars different, shouldn't getting collisions...
<script> $( document ).ready( function() { //pickers $.getjson( '/people.php', { get:'pickers' }, function( p ){ var poptions = ''; ( var pi=0; pi<=k['data'].length; pi++ ) { poptions += '<option value="' + p['data'][pi][0] + '">' + p['data'][pi][1] + ' (' + p['data'][pi][2] + ')</option>'; } $( '#selectpicker' ).html( poptions ); }); //grinners $.getjson( '/people.php', { get:'grinners' }, function( g ){ var goptions = ''; ( var gi=0; gi<=g['data'].length; gi++ ) { goptions += '<option value="' + g['data'][gi][0] + '">' + g['data'][gi][1] + ' (' + g['data'][gi][2] + ')</option>'; } $( '#selectgrinner' ).html( goptions ); }); }); </script>
the json looks (just fyi):
pickers;
{ "columns":["id","person","position"], "data":[[1,"jo bob","banjo"],[2,"garth waller","jug"],[3,"boswell higgins","washboard"]] }
grinners;
{ "columns":["id","person","relation"], "data":[[1,"jimmy john","grand-pappy"],[2,"margie monroe","grammy"],[3,"'big' tom turney","cousin/brother"]] }
if @ problem url catching solution add date request parameter url like,
'/people.php?d="+ new date()
where new date() current javascript date. optionaly can make 1 call , manage server code return both responce in one.
Comments
Post a Comment