Passing variables via json.parse

Passing variables via json.parse

Hi guys,

  Hopefully this is the place for this. I am pretty new to jQuery so bare with me please.
I have a wordpress site with dropdown menus that currently are working with jQuery, now the issue is when trying to dynamically update the menus and parsing it with json.parse. For some reason I am not getting any data back of the following code (if I try to alert (data) I just get a blank box).

  1.    function waitGoUpdate()
  2.    {
  3.        var $jQ = jQuery.noConflict ();
  4.        $jQ.ajax ({
  5.           type:     'GET',
  6.           url:      '/wp-content/plugins/xl-core/include/xl-core.php?d=m',
  7.           async:    true,
  8.           cache:    false,
  9.           success: function (data)
  10.           {
  11.               var json_data = JSON.parse (data);
  12.               $jQ('#div').html (json_data['div']);
  13.               //$('#messages').html (json_data['msgTotal']).show ();
  14.               setTimeout ('waitGoUpdate ()', 10000);
  15.           },
  16.           error: function (XMLHttpRequest, textStatus, errorThrown)
  17.           {
  18.              alert ("Status: " + textStatus + " (" + errorThrown +")");
  19.              setTimeout ('waitGoUpdate ()', 15000);
  20.           }
  21.        });
  22.    }

from the following php file.


  1.   function mf_menu_update ()
  2.   {
  3.      global $bp, $wpdb;
  4.      //return bp_core_fetch_avatar( array( 'item_id' => 2, 'type' => 'thumb', 'width' => 50, 'height' => 50 ));
  5.      $json_data  .= "<li style='width: 330px; height: 53px; verticle-align: center;'>
  6.                             <table style='background-color: #F2F2F2; cursor: pointer; width: 328px height: 50px; padding-left: 1px;'><tr>
  7.                             <td style='width: 50px;font-weight:normal;color:#555' valign='center'><img src='http://wp.moneyfriends.net/wp-content/plugins/buddypress/bp-core/images/mystery-man.jpg' style='width: 50px; height: 50px; border: 1px solid #fff;'></td>
  8.                             <td valign='top' style='font-weight:normal;color:#555'>&nbsp;<small><b><font color='#0099CC'>Subject:</font></b>&nbsp;{$msg_subject}...</small><br>
  9.                             &nbsp;<small><b><font color='#0099CC'>Date Sent:</font></b>&nbsp;{$bpq_messages ['date_sent']}</small></td></tr>
  10.                             <table></li>";
  11.       return json_encode ($json_data);
  12.   }
  13.   //print mf_menu_update (); -- this prints data on screen but will not pass to js get function.   
  14.   if (isSet ($_GET ['d']) && $_GET ['d'] == "m") {
  15.    print mf_menu_update();
  16.   }

if I was to remove

  1. if (isSet ($_GET ['d']) && $_GET ['d'] == "m") {
  2.    print mf_menu_update();
  3.   }

and just print out the function, than I would get the data on screen.
now if I was to access my php file directly than that fill will output an error due to missing plugins.. I guess that is just how wordpress sorta work.. but again I do get the info that i need by just printing out the function. Do anyone knows a work around for this? I am kinda pulling my hairs out. Any help will be appreciated.