When is it ok to use AJAX to access Firebase data? -


my question simple sounds.
when ok use ajax rather create new firebase() object when retrieving data?


i (ajax) or create new firebase object, better?

function get_user_data(user_id) {     var gotuserdata = $.deferred();      var username, userlastcheckin;      $.ajax({         datatype: "json",         url: datalocation + '/users/' + user_id + '.json',         type: "get",          success: function(data) {             if(data != null) {                 userdata = data;                 // console.log(userdata);                 username = data['username'];                 userlastcheckin = data['checkin'];             }         },      }).always(function () {         userinfo = [username, userlastcheckin];         gotuserdata.resolve();     });      return $.deferred(function (def) {         $.when(gotuserdata).done(function () {             def.resolve();         });     }); } 

i want know if secure?

i know firebase data sent , recieved on ssl, ajax on ssl when done in way?

the $.ajax() approach calls firebase's rest api , retrieves json object there. happens single time.

attaching listener same location start synchronizing data location client:

var ref = new firebase(datalocation); ref.child('users').child(user_id).on('value', function(snapshot) {     console.log(snapshot.val()); }); 

so same data, notified of updates tot data.

note 1 of changes. of these become clear read firebase guide web developers, highly recommend.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -