title: How to hide an onclick button inside ajax response?
body: <p>Could anyone tell me how i can hide/remove loadmore button when I receive certain response from ajax call(for example i got undefined or null value) ?I tried to use  $('#mango').hide(); but it didn't remove the button for me!But I received the alert which confirms that i got null or undefined value from api. Hope some one help me fix this .Thanks</p>
  
  <p>code:</p>
  
  
  
  <pre><code>&lt;script&gt;
  var maxnumId = null;
  function callApi() {
      $.ajax({
          type: "GET",
          dataType: "jsonp",
          cache: false,
          url: "https://api.somesite.com/......"),
          success: function(data) {
        maxnumId = data.pagination.next_num_id;
  
            if (maxnumId === undefined || maxnumId === null) {
  
                  alert('End!');
                   //remove the loadmore button here
                      $('#mango').hide();
                 }
          }
  
      });
  }
  &lt;/script&gt;
  &lt;body&gt;
  &lt;br&gt;
  &lt;center&gt;
  
  &lt;button id="mango" onclick="callApi()"&gt;Load More&lt;/button&gt;
  
  &lt;/html&gt;
  </code></pre>