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).
- function waitGoUpdate()
- {
- var $jQ = jQuery.noConflict ();
- $jQ.ajax ({
- type: 'GET',
- url: '/wp-content/plugins/xl-core/include/xl-core.php?d=m',
- async: true,
- cache: false,
- success: function (data)
- {
- var json_data = JSON.parse (data);
- $jQ('#div').html (json_data['div']);
- //$('#messages').html (json_data['msgTotal']).show ();
- setTimeout ('waitGoUpdate ()', 10000);
- },
- error: function (XMLHttpRequest, textStatus, errorThrown)
- {
- alert ("Status: " + textStatus + " (" + errorThrown +")");
- setTimeout ('waitGoUpdate ()', 15000);
- }
- });
- }
from the following php file.
- function mf_menu_update ()
- {
- global $bp, $wpdb;
- //return bp_core_fetch_avatar( array( 'item_id' => 2, 'type' => 'thumb', 'width' => 50, 'height' => 50 ));
- $json_data .= "<li style='width: 330px; height: 53px; verticle-align: center;'>
- <table style='background-color: #F2F2F2; cursor: pointer; width: 328px height: 50px; padding-left: 1px;'><tr>
- <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>
- <td valign='top' style='font-weight:normal;color:#555'> <small><b><font color='#0099CC'>Subject:</font></b> {$msg_subject}...</small><br>
- <small><b><font color='#0099CC'>Date Sent:</font></b> {$bpq_messages ['date_sent']}</small></td></tr>
- <table></li>";
- return json_encode ($json_data);
- }
- //print mf_menu_update (); -- this prints data on screen but will not pass to js get function.
- if (isSet ($_GET ['d']) && $_GET ['d'] == "m") {
- print mf_menu_update();
- }
if I was to remove
- if (isSet ($_GET ['d']) && $_GET ['d'] == "m") {
- print mf_menu_update();
- }
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.