# ajaxCold

[#](#rxdomrequestajaxcoldurl--settings)[Ⓢ](https://github.com/Reactive-Extensions/RxJS-DOM/blob/master/rx.dom.js#L145-L204) \[Ⓣ]\[1]

Creates a cold observable for an Ajax request with either a settings object with url, headers, etc or a string for a URL.

## Syntax

```javascript
// Using string URL
Rx.DOM.Request.ajaxCold(url);

// Using settings object
Rx.DOM.Request.ajaxCold(settings);
```

## Arguments

1. `url` _(String)_: A string of the URL to make the Ajax call.
2. `settings` _(Object)_: An object with the following properties
   * `url` _(String)_: URL of the request
     * `method` _(String)_: Method of the request, such as GET, POST, PUT, PATCH, DELETE
     * `async` _(Boolean)_: Whether the request is async
     * `headers` _(Object)_: Optional headers

## Returns

_(Observable)_: An observable sequence containing the `XMLHttpRequest`.

## Example

The following example uses a simple URL to retrieve a list of products.

```javascript
Rx.DOM.Request.ajaxCold('/products')
    .subscribe( 
        function (xhr) {

            var products = JSON.parse(xhr.responseText);

            products.forEach(function (product) {
                console.log(product);
            });
        },
        function (error) {
            // Log the error
        }
    );
```
