Issue on Updating a jQuery Function by Ajax and PHP
Can you please help me to figure out how to pass ajax result into a jquery function.
I have a HTML Select options as:
- <?php
- define('DB_HOSTNAME', 'xxxx');
- define('DB_USERNAME', 'xxxx');
- define('DB_PASSWORD', 'xxxx');
- define('DB_DATABASE', 'xxxx');
- $mysqli = new mysqli(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
- if ($mysqli->connect_errno) { die('Unable to connect!');}
- else{
- $query = 'SELECT DISTINCT projectID FROM DATA';
- if ($result = $mysqli->query($query)) {
- if ($result->num_rows > 0)
- {
- ?>
- <select id="selbycolo" class="selectpicker" data-live-search="true" data-size="5">
- <option value="select">Select From List</option>
- <?php
- while($row = $result->fetch_assoc()) {
- ?>
- <option value="<?php echo $row['projectID']; ?>"><?php echo $row['projectID']; ?></option>
- <?php
- }
- ?>
- </select>
- <?php
- }
- else { echo 'No records found!';}
- $result->close();
- }
- else {echo 'Error in query: $query. '.$mysqli->error;}
- }
- $mysqli->close();
- ?>
then I have an jQuery Ajax method as:
- <script type="text/javascript">
- $(document).ready(function(){
- $('#selbycolo').change(function()
- {
- if($(this).val() == '') return;
- $.get(
- 'ecolo.php',
- { id : $(this).val() },
- function(data)
- {
- //$('#result').html(data);
- }
- );
- });
- });
- </script>
and finally I have the ecolo.php which I would like to populate some
Plots
into another jquery function. Here is what I have
- <?php
- define('DB_HOSTNAME', 'xxxx');
- define('DB_USERNAME', 'xxxx');
- define('DB_PASSWORD', 'xxxx');
- define('DB_DATABASE', 'xxxx');
- $mysqli = new mysqli(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
- $resultStr = '';
- $query = 'SELECT * FROM DATA WHERE projectID='.$_GET['id'];
- if ($result = $mysqli->query($query))
- {
- if ($result->num_rows > 0)
- {
- while($row = $result->fetch_assoc())
- {
- }
- }
- else
- {
- $resultStr = 'Nothing found';
- }
- }
- echo $resultStr;
- ?>
now what I need to do is updating a jquery function
- 'Area 1': {
- latitude: 49.25,
- longitude: -123.10,
- tooltip: {
- content: "xzx"
- }
- }
In this script
- <script>
- $(function () {
- $(".maparea1").mapael({
- map: {
- name: "testmap",
- defaultArea: {
- attrs: {
- stroke: "#90856f",
- "stroke-width": 0.7,
- fill: "url(img/svg.png)"
- }
- }
- },
- plots: {
- 'Area 1': {
- latitude: 49.25,
- longitude: -123.10,
- tooltip: {
- content: "xzx"
- }
- }
- }
- });
- });
- </script>
which
'Area 1'
is coming from
area
column ,
latitude
from
lat
,
longitude
from
long
and content value from projectID. sorry this tools long but I tried to put every thing here by details.