There are a lot of way to take data via ajax.

I always use this one:

Client side:
    data = param1=foo&param2=bar
    $.ajax({
      type: "POST",
      url: "ajax.php",
      data: data,
      dataType: "json",
      success: function(data_result) { FillResult(data_result) }  //
on success the FillResult will be fired passing the result data from
the php call
    });


function FillResult(data) {
  $('#divtofill').html(data.param1+"<br />"+data.param2);
}

on server side:

<?php

$param1 = $_POST['param1']; // here you have to check if in post there
is the data you expect for security reasons
$param2 = $_POST['param2']; // here you have to check if in post there
is the data you expect for security reasons

// then you can retrieve your data in the way you want, I'm going to
return the posted data

json_encode($_POST); // this function comes from the json php
extension, which is included by default in php5, in php4 you can find
it via PECL.
?>

Hope this help.

Bye


On Nov 29, 10:34 pm, Action <[EMAIL PROTECTED]> wrote:
> I have a PHP array of data I want to be able to append to the html
> using jquery and ajax. I want to be able to add different elements of
> the array to different parts of the page.
>
> How can I go about doing this?

Reply via email to