title: Synchronous JSONP request
body: <p>There are many questions out there about JSONP requests and the fact that they cannot be made synchronously. Most workarounds involve using the callbacks, or the success function in an ajax request to do what you want, but I don't think that's going to work for me. </p>
  
  <p>Background: I'm working on a search application using <a href="http://lucene.apache.org/solr/" rel="nofollow">Solr</a>. I'm developing a javascript API for others to use to interact with Solr so they don't need to understand the ins and outs of a Solr search request. </p>
  
  <p>In my api, I have a Request object, with a function called doRequest. The purpose of the function is to perform the call to the solr server (on another domain, thus the need for JSONP), and return a Response object. </p>
  
  <pre><code>Request.prototype.doRequest = function (){
  var res = new Response();
  $.ajax({
      url: this.baseURL,
      data: 'q=*:*&amp;start=0&amp;rows=10&amp;indent=on&amp;wt=json', 
      success: function(data){
          res.response = data.response;
          res.responseHeader = data.responseHeader;
          /*
            other...
            stuff...
          */
      },
      dataType: 'jsonp',
      jsonp: 'json.wrf'
  });
  res.request = this;
  return res;
  };
  </code></pre>
  
  <p>The "user" would use this function like so... </p>
  
  <pre><code>var req = new Request();
  var res = req.doRequest();
  </code></pre>
  
  <p>and then do something or other with the results in res.</p>
  
  <p>Given that I cannot do a synchronous JSONP request, and I cannot return from within the ajax function, I can't figure out anyway to make sure res is fully populated for the user before they start using it.</p>
  
  <p>Thanks,</p>