Live notification Ajax not work
-
Hi,
I need to create ajax notification popup when one query return true. My code from plugin is below:
jQueryjQuery(document).ready(function(){ setInterval(function(){ load_last_notification(); }, 5000); function load_last_notification() { $.ajax({ url:"file.php", method:"POST", dataType: "JSON", success:function(data) { var respose = JSON.parse(data); $('.request-notification').html(respose); } }) } });
In my page exist:
<div class="request-notification"></div>
file.php
global $wpdb; $current_user = get_current_user_id(); $output = ''; $thread_id_request = $wpdb->get_var( $wpdb->prepare( " SELECT <code>thread_id</code> FROM <code>{$wpdb->base_prefix}table</code> WHERE <code>user_id</code> = %d AND <code>accept_status</code> = 0 ", $current_user ) ); if($thread_id_request){ $output .= '<div>Test from the other side</div>'; } json_encode($output);
What is wrong? or How I can create live notification for user when query return true?
Thanks for support and time!
The page I need help with: [log in to see the link]
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Live notification Ajax not work’ is closed to new replies.