title: How to run ajax in wamp server
body: <p>I am working on ajax for days now and it still won't work. So I decided to download a sample program using ajax but it still won't work. Is there something wrong with my server? This doens't return any error. But it does not show my jquery.</p>
  
  <p>client.php</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;html&gt;
    &lt;head&gt;
      &lt;script language="javascript" type="text/javascript" src="jquery.js"&gt;&lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
  
    &lt;!---------------------------------------------------------------------------------------------
    1) Create some html content that can be accessed by jquery
    ----------------------------------------------------------------------------------------------&gt;
    &lt;h2&gt; Client example &lt;/h2&gt;
    &lt;h3&gt;Output: &lt;/h3&gt;
    &lt;div id="output"&gt;this element will be accessed by jquery and this text will be replaced&lt;/div&gt;
  
    &lt;script id="source" language="javascript" type="text/javascript"&gt;
  
    $(function () 
    {
  
      //-------------------------------------------------------------------------------------------
      // 2) Send a http request with AJAX http://api.jquery.com/jQuery.ajax/
      //-------------------------------------------------------------------------------------------
      $.ajax({                                      
        url: 'api.php',                  //the script to call to get data          
        data: "",                        //you can insert url argumnets here to pass to api.php for example "id=5&amp;parent=6"
        dataType: 'json',                //data format      
        success: function(data)          //on recieve of reply
        {
          var id = data[0];              //get id
          var vname = data[1];           //get name
          //--------------------------------------------------------------------------------------
          // 3) Update html content
          //--------------------------------------------------------------------------------------
          $('#output').html("&lt;b&gt;id: &lt;/b&gt;"+id+"&lt;b&gt; name: &lt;/b&gt;"+vname);     //Set output element html
          //recommend reading up on jquery selectors they are awesome http://api.jquery.com/category/selectors/
        } 
      });
  
    }); 
    &lt;/script&gt;
  
    &lt;/body&gt;
  &lt;/html&gt;  
  </code></pre>
  
  <p>api.php</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;?php 
  
    //------------------------------------------------------------------------
    //--------------------------------------------------------------------------
    $host = "localhost";
    $user = "root";
    $pass = "root";
  
    $databaseName = "ajax01";
    $tableName = "variables";
  
    //--------------------------------------------------------------------------
    // 1) Connect to mysql database
    //--------------------------------------------------------------------------
  
    $con = mysql_connect($host,$user,$pass);
    $dbs = mysql_select_db($databaseName, $con);
  
    //--------------------------------------------------------------------------
    // 2) Query database for data
    //--------------------------------------------------------------------------
    $result = mysql_query("SELECT * FROM $tableName");            //query
    $array = mysql_fetch_row($result);                          //fetch result    
  
    //--------------------------------------------------------------------------
    // 3) echo result as json 
    //--------------------------------------------------------------------------
    echo json_encode($array);
  
  ?&gt;
  </code></pre>