title: How to pass response data from ajax succes to callback function?
body: <pre><code>(function($)
  {
  
      $.fn.makeAjaxPostCall = function(options)
          {
              var settings = $.extend( true,{}, $.fn.makeAjaxPostCall.defaults, options );
              $.ajax({
                  type: 'POST',
                  url:  settings.url,
                  data:   settings.data,
                  success: function(data, textStatus, xhr){
                      if (xhr.readyState === 4 &amp;&amp; xhr.status === 0) {
  
                          alert('Network Error');
                      }
                      else {alert(data);
                          settings.callback.call(data);
                      }
                  },
                  error: function(xhr, textStatus, errorThrown) {
                      if (textStatus !== null) {
                          alert("error: " + textStatus);
                      } else if (errorThrown !== null) {
                          alert("exception: " + errorThrown.message);
                      }
                      else {
                          alert ("error");
                      }
                  }
              });
          };
          $.fn.makeAjaxPostCall.defaults = {
              type : 'POST',
              url : '',
              data : {},
              obj : $(document),
              callback : function(data){}
          };
  
  })(jQuery);
  </code></pre>
  
  <p>This is my ajax function. And I am calling this function as</p>
  
  <pre><code>$(document).makeAjaxPostCall({
      type : 'POST',
      url : 'UpdateNodeStatus',
      data : {
          workshopid : 1,
          userid : 1001,
          level : 5,
          nodeid : 10,
          resolutionid : 1
      },
      callback : function(data){
          alert(data);
      }
  });
  </code></pre>
  
  <p>after post happened I am returning 'true' from servlet. </p>
  
  <pre><code>response.setContentType("text");
      PrintWriter pw = response.getWriter();
      pw.print(true);
  </code></pre>
  
  <p>I am getting data as 'true' in 'success', but as 'undefined' in callback. </p>
  
  <p>How do I pass 'data' from 'success' to 'callback' function to use it in there?</p>