No, I don't get alert. That means it's failing silently.

I've tested the functions.php (by running it) and it ouputs the data
in JSON format.
So retrieveing and echo'ing the data works fine.

It's the jQuery that I got wrong.

1. How do I call a specific funtion within functions.php? I got a "bad
feeling" that  func: "getStoreInformation" is just an input parameter
and has nothing to do with calling the function getSToreInformation().
2. I need to pass the storeID. I get this with the folloing line: "var
storeID = this.cells[0].innerHTML;".
I guess I should pass it as parameter:   jQuery.post("../
functions.php", { func: "getStoreInformation", sID: storeID  }
But I don't think I can use " sID: storeID ".


Steven


On 16 Apr, 14:13, Josch <jluelsd...@googlemail.com> wrote:
> Do you get an empty alert or nothing?
>
> On 16 Apr., 12:13, spstieng <spsti...@hotmail.com> wrote:
>
>
>
> > 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