title: How to use outputs of php that is called by ajax in our file
body: <p>I have an app that sends latitude, longitude values to my postgresql database. And i want to plot the updated points accordingly on my OpenLayers map using jquery,ajax. But here is where i am stuck at: When I click the button, the php file with database connection and saving the last entry of the table in an array is happening. </p>
  
  <p>But when i try using the outputs in markers, nothing is happening.</p>
  
  <p>How to use the output values of the php in my function?</p>
  
  <p>Here is the code that i am trying to use.</p>
  
  <p>php file: </p>
  
  <pre><code>&lt;?php
  $conn = pg_connect("host=xxx port=xxx dbname=xx user=postgres password=xxx");
  $result = pg_exec($conn,"Query goes here");
  $numrows = pg_numrows($result);
  for($ri = 0; $ri &lt; $numrows; $ri++)
  {
  $row = pg_fetch_array($result, $ri);
  $data = array(); // create a variable to hold the information
    $lat_latest[] = $row["latitude"];
  $long_latest[] = $row["longitude"];  // add the row in to the results (data) array
  }
  pg_close($conn);
  $js_lat = json_encode($lat_latest);
  echo "var javascript_lat1 = ". $js_lat . ";\n";
  $js_long = json_encode($long_latest);
  echo "var javascript_long1 = ". $js_long . ";\n";
  ?&gt;
  </code></pre>
  
  <p>My page code is :</p>
  
  <pre><code>function init(){
  //openlayers map code is here.
      $("button").click(function(){
      $.get("dataconn.php",function(data,status){
  
      alert("Data:"+data+"Status:" +status);
      var extra_point = new OpenLayers.Feature.Vector(
       new OpenLayers.Geometry.Point(parseFloat(javascript_long1[0]),parseFloat(javascript_lat1[0])),
       {some:'data'},
       {externalGraphic: 'images1/marker-gold.png', graphicHeight: 16, graphicWidth: 16});
       vectorLayer1.addFeatures([extra_point]);
      });
      });
      }
      &lt;/script&gt;
      &lt;/head&gt;
      &lt;body onload='init();'&gt;
      &lt;div id="map" style = 'width: 1075px; height: 485px'&gt;
      &lt;button&gt; Update &lt;/button&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>and the alert i am getting when clicking update button is</p>
  
  <pre><code>Data: 
  var javascript_lat1 = ["output of the query"];
  var javascript_long1 = ["output of the query"];
  Status : success
  </code></pre>
  
  <p>Is the way i am trying to access the values of query output correct? Please help.
  Sorry if this is a dumb question. I am new to jquery.</p>