DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Guides
  • Core
  • Ecosystem
    • can-construct-super
    • can-define-stream
    • can-fixture
      • types
        • Store
        • ajaxSettings
        • request
        • requestHandler
        • response
      • properties
        • delay
        • on
        • rand
        • store
    • can-fixture-socket
    • can-jquery
    • can-stache-converters
    • can-stream
    • can-vdom
    • can-view-import
    • can-zone
    • steal-stache
  • Infrastructure
  • Legacy
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Ecosystem
  • /
  • can-fixture
  • /
  • requestHandler
  • / On this page
    • requestHandler

      typedef
      • source

      requestHandler(request, response(...), requestHeaders, ajaxSettings)

      Defines the XHR response for a given trapped request.

      fixture({method: "get", url: "/todos"},
        function(request, response, headers, ajaxSettings){
          request //-> {
                  //    method: "get",
                  //    url: "/todos",
                  //    data: {complete: true}
                  //   }
      
        }
      });
      
      $.ajax({ method: "get", url: "/todos?complete=true" })
      

      Templated url data will be added to the requestHandler's request argument's data property:

      fixture({url: "/todos/{action}"},
        function(request, response, headers, ajaxSettings){
          request //-> {
                  //    method: "post",
                  //    url: "/todos",
                  //    data: {action: delete}
                  //   }
        }
      });
      
      $.post("/todos/delete");
      

      Parameters

      1. request {request}:

        Information about the request. The request's data property will contain data from the request's querystring or request body. Also any templated values in the ajaxSettings's url will be added.

      2. response {response()}:

        A callback function that provides response information.

      3. requestHeaders {Object}:

        Headers used to make the request.

      4. ajaxSettings {Object}:

        The settings object used to match this request.

      CanJS is part of DoneJS. Created and maintained by the core DoneJS team and Bitovi. Currently 3.0.0.