php - How can I embed the AJAX output of JS in Javascript function -


it's becoming nightmare me solving problem. developing app using phonegap. have used highcharts in graphs. graph coming not tooltip in graph. please check code below, need code able show tooltip proper data. there has loop of following code , has every user or series in graph. have ran loop in php , saved in variable , got whole output of loop using ajax in json format.

when use variable in javascript code in have saved ajax output, doesn't if alert alerts exact code want make tooltip work. have tried eval() no benefit. or guidance appreciated.

loop code

        $tooltip = '';          for($i=0;$i<$teamcontrollerw->total_user;$i++){             $tooltip .= "var chart = $('#team_containerwf').highcharts();";             $tooltip .= "var figures".$i." = [".join($teamcontrollerw->new_yaxesdata1[$i], ",") ."]; ";             $tooltip .= "var fatvals".$i." = [". join($teamcontrollerw->fatval[$i], ',') ."]; ";             $tooltip .= "var weightvals".$i." = [". join($teamcontrollerw->weightval[$i], ',') ."]; ";             $tooltip .= "var result_playing_dates = [". join($teamcontrollerw->new_playing_dates_data[$i], ',') ."]; ";             $tooltip .= "             $.each(figures".$i.", function (j, figure".$i.") {                  var curdanger = (figure".$i."[0] - danger[0][0]) * delta + danger[0][1];                  var play_date = false;                  (var k = 0; k < result_playing_dates.length ; k ++ ) {                     if (figure".$i."[0] == result_playing_dates[k]) {                         play_date = true;                         break;                     }                  }                  ";                  $tooltip .= "if (figure".$i."[1] > curdanger) {                     if (play_date) {                         if (chart.series[".$i."].data[j] && chart.series[".$i."].data[j].graphic) {                             chart.series[".$i."].data[j].graphic.attr({ fill: '#a31515' });                              chart.series[".$i."].data[j].update({                              fatval : fatvals".$i."[j],                              weightval : weightvals".$i."[j],                              marker:{                                 fillcolor: '#a31515',                                 radius: 6,                                 states: {                                       hover: {                                          fillcolor: '#a31515',                                          linecolor: '#a31515',                                          radius: 10                                       }                                    }                                 }                              });                         }                      }                      else {                         if (chart.series[".$i."].data[j] && chart.series[".$i."].data[j].graphic) {                             chart.series[".$i."].data[j].graphic.attr({ fill: 'red' });                             chart.series[".$i."].data[j].update({                             fatval : fatvals".$i."[j],                             weightval : weightvals".$i."[j],                             marker:{                                fillcolor: 'red',                                states: {                                      hover: {                                         fillcolor: 'red',                                         linecolor: 'red'                                                                          }                                   }                                }                             });                         }                     }                 }else{                     if (play_date) {                         if (chart.series[".$i."].data[j] && chart.series[".$i."].data[j].graphic) {                             chart.series[".$i."].data[j].graphic.attr({ fill: '#02491a' });                             chart.series[".$i."].data[j].update({                             fatval : fatvals".$i."[j],                             weightval : weightvals".$i."[j],                             marker:{                                  fillcolor: '#02491a',                                  radius: 6,                                  states: {                                        hover: {                                         fillcolor: '#02491a',                                         linecolor: '#02491a',                                         radius: 10                                        }                                     }                                  }                             });                         }                      }                      else {                         if (chart.series[".$i."].data[j] && chart.series[".$i."].data[j].graphic) {                             chart.series[".$i."].data[j].graphic.attr({ fill: 'green' });                             chart.series[".$i."].data[j].update({                             fatval : fatvals".$i."[j],                             weightval : weightvals".$i."[j],                             marker:{                                fillcolor: 'green',                                states: {                                      hover: {                                         fillcolor: 'green',                                         linecolor: 'green'                                                                        }                                   }                                }                             });                         }                     }                  }             });             ";       }//end 

i'm calling data this

    var teamweighinlmgameaction = window.localstorage.getitem("teamweighinlmgameaction");     agweigh = json.parse(teamweighinlmgameaction);     var tooltip = agweigh.tooltip;      alert(tooltip);//on alert comes fine      if(data_avail=='yes') { //check if data available         var danger = mydangerline,         deltax = danger[1][0] - danger[0][0],         deltay = danger[1][1] - danger[0][1],         delta = deltay / deltax;          alert("in: "+tooltip);//the data alerts fine here          tooltip; //this place need loop output nothing comes      } 

ok sounds "loop code" being result of ajax call has passed js code "var chart = $('#team_containerwf').highcharts();..."!! however, never executed main page. ajax result being passed should ideally json/xml , contain name value pairs of data. such main code being viewed would:

  1. validate name value pairs
  2. execute own code render graph based on name value pairs

therefore, recommendation try structure firstly main page handles logic display in javascript, , ajax pages in php handle logic pulling data , not display.

also provide bit more detail on structure of project. label code e.g. index.php getchartplayingdates.php?


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -