[wp-hackers] wp_send_json_success not working with array?
David Ernst
david at ernsts.us
Wed Jan 1 05:49:35 UTC 2014
Hey Greg— do you have skype? I really admire your attitude. Happy New Years!
—David
On Tuesday, December 31, 2013, BenderisGreat wrote:
> Here is my code - The goal is to return the database data formatted to
> update
> a JS chart. For some reason the function isnt even seeing the $chartData
> as
> executing. if ($chartData) returns false.
>
> function ams_chart_range_selection() {
> global $wpdb, $_current_member;
>
>
> $range = $_POST['range'];
> $limit = 5;
> if ($range == 'week' )
> $limit = 7;
> elseif ($range == 'month') {
> $limit = 30;
> } else
> $limit = 90;
>
>
> $logDataTable = $wpdb->prefix . 'jo_plugin_options';
> $chartData = $wpdb->get_results( $wpdb->prepare("SELECT * FROM
> $logDataTable WHERE user_id = %d ORDER BY date ASC LIMIT %d",
> $_current_member->ID, $limit), ARRAY_A );
>
> $max = count($chartData);
> $converted = array();
> $counter = 0;
>
> foreach ($chartData as $item) {
> $converted[] = "[".$counter++.",".$item['date']."]";
> $list = implode(",",$converted);
> }
>
> if (!$chartData) {
> wp_send_json_error();
>
> } else {
>
> $data = array(
> 'range' => $range,
> 'list' => $list );
>
>
> wp_send_json_success($data);
>
>
> }
>
>
> }
>
>
>
> --
> View this message in context:
> http://wordpress-hackers.1065353.n5.nabble.com/wp-send-json-success-not-working-with-array-tp43098.html
> Sent from the Wordpress Hackers mailing list archive at Nabble.com.
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com <javascript:;>
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
More information about the wp-hackers
mailing list