31 March, 2015

REST Call Using jQuery AJAX

Here you can see how you can make REST service call using jQuery :




$(document).on('ready',function(){
            var username ="vachhani_22kk@yahoo.com";
            var password ="password"; 
            function make_base_auth(user, password) {
              var tok = user + ':' + password;
              var hash = btoa(tok);
              return "Basic " + hash;
            }
                $.ajax({
                  url: 'http://google.com/api/jsonws/ocd-ws-portlet.ocdwebs/get-folder-files/folder-id/22793/repository-id/12368',
                  dataType: "json",
                  data:{},
                  type: "get",
                  success: function(data){
                          alert("hi");
                  },
                  beforeSend: function(xhr){
                          xhr.setRequestHeader('Authorization',make_base_auth(username, password));
                                    },
                                    complete: function(){
                                    },
                  error: function(){
                  }
                });
             
 });

Popular Posts

Featured Post

Liferay 7.3 compatibility matrix

Compatibility Matrix Liferay's general policy is to test Liferay Portal CE against newer major releases of operating systems, open s...