# JavaScript - Cannot index new data (on client side)

**URL:** <https://discuss.elastic.co/t/javascript-cannot-index-new-data-on-client-side/65555>\
**Category:** Elasticsearch\
**Created:** [November 9, 2016, 8:18pm UTC](https://discuss.elastic.co/t/javascript-cannot-index-new-data-on-client-side/65555 "2016-11-09T20:18:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![totessusan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/totessusan/32/13028_2.png) [@totessusan](https://discuss.elastic.co/u/totessusan)\
**Post date:** [November 9, 2016, 8:18pm UTC](https://discuss.elastic.co/t/javascript-cannot-index-new-data-on-client-side/65555/1 "2016-11-09T20:18:31Z")

</div>

I have a #elastic-submit on a search submit button - every time someone clicks it, I want to grab their IP address and index the new data into my existing index called "html5-es-search." It took me a long time to figure out how to attain the IP address, but now that I'm able to - it seems that the elastic client only has a valid function for close(). There is no create() or index(). Can someone please help me? What am I doing wrong?

```
    $("#elastic-submit").click(function (e) {
        $.getJSON("https://api.ipify.org?format=jsonp&callback=?",
            function(json)
            {
                var searchField = document.getElementById("elastic");

                if (searchField != null)
                {
                    ConnectToES();

                    var input = $(searchField).val();
                    var target = _"html5-es-search";
                    var result = client.index({
                        "index": target,
                        "body": {
                            "ip_address": json.id,
                            "input": input
                        }
                    }, function (error, resp) {
                        console.log(resp);
                    });
                }
            }
        );
    });

```

 ![](https://us1.discourse-cdn.com/elastic/original/2X/a/a057ba11f8af261d84219f0ca9a77f7fc77f666f.png)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 7, 2016, 8:18pm UTC](https://discuss.elastic.co/t/javascript-cannot-index-new-data-on-client-side/65555/2 "2016-12-07T20:18:49Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
