How to link php database file in javascript?

I have a Jvector Map since by default the Jvector displays its working freeze function. Now I changed the hover to click the function. But now I want to display country data from a database. I created a php database? I do not know how to call my php database file?

the code:

<!DOCTYPE html>
<html>

<head>
  <title>Country Footprint</title>
  <link rel="stylesheet" media="all" href="../jquery-jvectormap.css"/>
  <script src="assets/jquery-1.8.2.js"></script>
  <-- jvectormap scripts here -->
  <script>
    jQuery.noConflict();
    jQuery(function(){
      var $ = jQuery;
      $('#focus-single').click(function(){
        $('#map1').vectorMap('set', 'focus', {region: 'AU', animate: true});
      });
      $('#focus-multiple').click(function(){
        $('#map1').vectorMap('set', 'focus', {regions: ['AU', 'JP'], animate: true});
      });
      $('#focus-coords').click(function(){
        $('#map1').vectorMap('set', 'focus', {scale: 7, lat: 35, lng: 33, animate: true});
      });
      $('#focus-init').click(function(){
        $('#map1').vectorMap('set', 'focus', {scale: 1, x: 0.5, y: 0.5, animate: true});
      });

      $('#map1').vectorMap({
        map: 'world_mill_en',
        panOnDrag: true,
        focusOn: {
          x: 0.5,
          y: 0.5,
          scale: 1,
          animate: true
        },
        series: {
          regions: [{
            scale: ['#688FA0'],
            normalizeFunction: 'polynomial',
+4
source share
1 answer

The answer is simple, but you will need to make some more codes.

First of all, you need to understand that a JavaScript application cannot directly connect to your database (and if that were possible, you would need to store your credentials in your JS application and disclose them to everyone there).

JavaScript AJAX - - (, http://example.com/getdata.php), JSON. JS.

getdata.php script PHP script, JSON ( Content-Type: application/json).

+2

All Articles