javascript - Variable is undefined error (even if console.log shows variable) -


my function looks that

var mail_ntfy=$("#nav_mail"), question_ntfy=$("#nav_question"), users_ntfy=$("#nav_users"); function checkall(){     var data=checkfor("m,q,u");     if(mail_ntfy.attr("data-number")!=data.m_count && data.m_count!=0)         mail_ntfy.attr("data-number", data.m_count);     if(question_ntfy.attr("data-number")!=data.q_count && data.q_count!=0)         question_ntfy.attr("data-number", data.q_count);     if(users_ntfy.attr("data-number")!=data.u_count && data.u_count!=0)         users_ntfy.attr("data-number", data.u-count);     shownotes(data.msg);     chngtitle(data.msg);     }  $(document).ready(function () {     setinterval(checkall(), 10000); })  function checkfor(param){         $.ajax({         url: "core/notifications.php",         type: "post",         datatype: "json",         data: {             chk:param         },         success: function (data) {              if(data.status!="error")  {                 console.log(data);                 return data;                             }          }     }); } 

i got 2 questions:

1) see that, checkfor function returns result (console.log shows result) still getting data undefined error message on line if(mail_ntfy.attr("data-number")!=data.m_count && data.m_count!=0). missing?

2) want execute, checkall in every 10 seconds. doesn't start more 1 time. why setinterval doesn't work properly?

checkfor() not return result. console.log() statement in anonymous function attached success handler of ajax request; return not return checkfor() function.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -