# Insert Record from AJAX - Not working

**URL:** <https://discuss.elastic.co/t/insert-record-from-ajax-not-working/17369>\
**Category:** Elasticsearch\
**Created:** [May 6, 2014, 12:59pm UTC](https://discuss.elastic.co/t/insert-record-from-ajax-not-working/17369 "2014-05-06T12:59:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![raghav280392](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raghav280392/32/558_2.png) [@raghav280392](https://discuss.elastic.co/u/raghav280392)\
**Post date:** [May 6, 2014, 12:59pm UTC](https://discuss.elastic.co/t/insert-record-from-ajax-not-working/17369/1 "2014-05-06T12:59:43Z")

</div>

Hi  
I am able to search in elastic search with AJAX. But I am not able insert  
record with AJAX. Can someone help me..

var attr={  
"username":"username",  
"password":"password"  
};

$.ajax( {  
url: '[http://localhost:9200/'+'objects'+'/'+'saved\_queries1/1/](http://localhost:9200/'+'objects'+'/'+'saved_queries1/1/)',  
type: 'POST',  
crossDomain: true,  
dataType: 'json',  
data: JSON.stringify(attr),  
success: function(response) {  
console.log("SUCCESS");  
},  
error: function(jqXHR, textStatus, errorThrown) {  
console.log("ERROR");  
}  
});

}

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/67c75595-414a-475b-bdd5-be40af321fce%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/67c75595-414a-475b-bdd5-be40af321fce%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![vineeth\_mohan\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vineeth_mohan_2/32/747_2.png) [@vineeth\_mohan\_2](https://discuss.elastic.co/u/vineeth_mohan_2)\
**Post date:** [May 7, 2014, 12:40pm UTC](https://discuss.elastic.co/t/insert-record-from-ajax-not-working/17369/2 "2014-05-07T12:40:03Z")

</div>

Hi ,

Can you look into firebug and say what its returning.

Thanks  
Vineeth

On Tue, May 6, 2014 at 6:29 PM, Raghavendar T S [raghav280392@gmail.com](mailto:raghav280392@gmail.com)wrote:

> Hi  
> I am able to search in Elasticsearch with AJAX. But I am not able insert  
> record with AJAX. Can someone help me..
> 
> var attr={  
> "username":"username",  
> "password":"password"  
> };
> 
> $.ajax( {  
> url: '[http://localhost:9200/'+'objects'+'/'+'saved\_queries1/1/](http://localhost:9200/'+'objects'+'/'+'saved_queries1/1/)',  
> type: 'POST',  
> crossDomain: true,  
> dataType: 'json',  
> data: JSON.stringify(attr),  
> success: function(response) {  
> console.log("SUCCESS");  
> },  
> error: function(jqXHR, textStatus, errorThrown) {  
> console.log("ERROR");  
> }  
> });
> 
> }
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/67c75595-414a-475b-bdd5-be40af321fce%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/67c75595-414a-475b-bdd5-be40af321fce%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/67c75595-414a-475b-bdd5-be40af321fce%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/67c75595-414a-475b-bdd5-be40af321fce%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAGdPd5%3DM1TC2KowAM\_R%3Ddq44XPbrz4Cxd5S\_LqUdoLdvLUwRvQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGdPd5%3DM1TC2KowAM_R%3Ddq44XPbrz4Cxd5S_LqUdoLdvLUwRvQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [July 6, 2017, 1:31am UTC](https://discuss.elastic.co/t/insert-record-from-ajax-not-working/17369/3 "2017-07-06T01:31:06Z")

</div>


