Satheesh Kumar Satheesh Kumar - 25 days ago 9
Ajax Question

Get JSON content by using ajax in Firebase console

I have just created a dynamic page by using firebase console. It's working as my expectation. But instead of using javascript to retrieve data from firebase database, is there any possibilities to use

ajax
method to retrieve, edit, delete the json content, which is in firebase.

Answer Source

Firebase expects the body to be a JSON string, so you'll need to stringify it:

$(document).ready(function () {
   var param = {data: "value", data: "value"};

   $.ajax({
     url: 'https://yourdbatfirebase.firebaseio.com/.json',
     type: "POST",
     data: JSON.stringify(param),
     success: function () {
       alert("success");
     },
     error: function(error) {
       alert("error: "+error);
     }
   });
 });

This will accomplish the same by the way:

$.post('https://yourdbatfirebase.firebaseio.com/.json',
  JSON.stringify(param),
  function () {
    alert("success");
  }
);