title: Error in sending data from background.js to popup.js in chrome extension
body: <p>I am creating a chrome extension. In that I am getting problem in sending message from background.js to popup.js.  I am successfull in sending some static data from background.js to popup.js. But, when I try to send data dynamically (i.e. the data sent to background.js by content-script.js) from background.js to popup.js, it is giving undefined as I print it on popup.html.  </p>
  
  <p>This is my popup.js: </p>
  
  <pre><code> var value;
    window.onload = function(){   
      chrome.runtime.sendMessage({getVal: "Hi"}, function(response){
      value = response.responseSeltext;
      alert(value);
      });
      document.getElementById('save').onclick = test;
  }
  </code></pre>
  
  <p>This is my background.js:</p>
  
  <pre><code>    var seltext;
          chrome.runtime.onMessage.addListener(
          function(request, sender, sendResponse) {
  
          if (request.ezynotes != ""){
            seltext = request.ezynotes;
            alert("In extension "+seltext);
  
            //document.getElementById("notes").innerHTML += request.ezynotes;
           }
          if (request.getVal != ""){
            sendResponse({responseSeltext:seltext});
  
            //seltext = request.ezynotes;
            alert("In extension "+seltext);
  
            //document.getElementById("notes").innerHTML += request.ezynotes;
           }
  
    });
  </code></pre>