Populate inputs from ajax call

Populate inputs from ajax call

Hi all,

I'm trying to create a function which sends a ajax call and checks a database for entries. If the number sepcified is found in the data, jquery is to populate some input fields with the result.

Example: I looking for 210 and the database found a user with this number, then the ajax returns some information like name, address, postal and city.

I created a database call which in a php file created a array with the result:
$user[] = array('name' => $row->name,'address' => $row->address,'postal' => $row->postal,'city' => $row->city);

Now I can't figure out how to return this array into the jquery function and populate the right html inputs.

$.post("findUser.php", { 'phoneNumber': number },
    function(data){
   
        //Here is where I want to split the data string returned and inserted into the 4 inputs
        $('#nameInput').html(data from array which holds the name);
        $('#addressInput').html(data from array which holds the address);
        ...

    }, "xhtml");

Hope you understand...