ajax function

Future<Response> ajax(
  1. Uri url, {
  2. String method = "GET",
  3. List<int>? data,
  4. String? body,
  5. Map<String, String>? headers,
  6. Duration? timeout,
})

Sends an Ajax request to the given url and returns the response.

Same semantics as package:http's top-level functions (http.get, http.put, …): body is buffered into the returned http.Response. Pass bytes via data or a string via body.

  • timeout bounds the entire request — connect, send, response, and body read. If exceeded, the underlying HttpClient is force-closed (releasing the socket immediately) and TimeoutException is thrown. package:http's top-level functions cannot do this — they construct an internal Client and give no handle to force-close.

Implementation

Future<http.Response> ajax(Uri url, {String method = "GET",
    List<int>? data, String? body, Map<String, String>? headers,
    Duration? timeout})
=> _ajax(url, method: method, data: data, body: body, headers: headers,
    timeout: timeout, getResponse: http.Response.fromStream);