Cannot display returned JSON from a JQUERY AJAX call in CodeIgniter

Posted by Obay on Stack Overflow See other posts from Stack Overflow or by Obay
Published on 2010-03-24T02:03:23Z Indexed on 2010/03/24 2:13 UTC
Read the original article Hit count: 520

Filed under:
|
|
|

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?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about AJAX