title: wrapping jquery ajax in function with return
body: <p>I am trying to make some of my javascript a bit more testable, as part of this I am wrapping up certain functionality in classes so I can mock it out in my tests.</p>
  
  <p>Anyway I am trying to wrap up my ajax, so as far as my app would be concerned it is asking a service for an object. Internally it would make an ajax request and then do something with the data and then return it.</p>
  
  <p>So would something like the example below be possible? (I am on the move at the moment so cant try it for myself)</p>
  
  <pre><code>function SomeAjaxService(webServiceUrl)
  {
      this.getSomeModel = function(someUniqueId){
          var ajaxOptions = {
              url: webServiceUrl,
              data: {id : someUniqueId},
              Success: function(data) { return new SomeModel(data); }
          };
          $.ajax(ajaxOptions);
      };
  }
  
  var ajaxService = new SomeAjaxService("http://someurl");
  var myModel = ajaxService.getSomeModel(1);
  </code></pre>
  
  <p>As ajax is asynchronous by nature, I think you can set it to be synchronous but I just wanted to check what the options were...</p>