views:

198

answers:

1

Im using JQUERY + CodeIgniter. I can't seem to get the returned data to display after an ajax call.

Here is my JQUERY:

  $.post("<?= site_url('plan/get_conflict') ?>", {
    user_id : user_id,
    datetime_from : plan_datetime_start,
    datetime_to : plan_datetime_end,
    json : true
   }, function(data) {
    alert(data);
     }, "json");

Here is my CodeIgniter:

function get_conflict() {
    ...
 log_message("debug","get_conflict(): $result");
 return $result;
}

My logs show:

get_conflict(): {"work_product_name":"Functional Design Document","datetime_start_plan":"2010-04-22 08:00:00","datetime_end_plan":"2010-04-22 09:00:00","overlap_seconds":3600}

Meaning the JSON is being returned correctly. However, the alert(data) nor alert(data.work_product_name) are not displayed.

Any ideas?

+1  A: 

You are returning the result... you should be outputting it.

For example

function get_conflict() {
    ...
    log_message("debug","get_conflict(): $result");

    $this->output->set_output( json_encode($result) );
}
Dyllon
it works!! thanks man!!!
Obay