Hi, I'm trying to use jQuery.post() function to retrieve som data. But
i get no ouput.

My PHP file looks like this:

<?php
  inlcude_once('dal.php');

  //Get store data, and ouput it as JSON.
  function getStoreInformation($storeID)
  {
    $sl = new storeLocator();
    $result = $sl->getStoreData($storeID);

    while ($row = mysqli_fetch_assoc($result)) {
    {
        $arr[] = $row;
    }
    $storeData = json_encode($arr);
    echo $storeData;  //Output JSON data
  }
?>

This is my javascript which is located in /js/myscripts.js

jQuery(document).ready(function() {
  jQuery('#storeListTable tr').click(function() {
    jQuery.post("../functions.php", { func: "getStoreInformation" },
    function(data){
       alert(data.name); // To test if I get any output
       //$('#store_name').val(data.name);   // I could do this to
populate my form
      //$(#store_data_form).populate(data, {debug:1})  //But I
probably will use jQuery "Populate" plugin instead
    }, "json");
  });
});

If this is working, I should be able to get an alert message, right?

Reply via email to