Sunday, March 20, 2016

JQuery $.ajax




  var fisInformationService = module.service("fis_info", function (_request) {

    /**
     *
     * @param {Array.String} String of contexts for which to get related getInformation.
     * @param {Function} Passed the received messages.
     */

    this.getInformation = function (syncflag, apiField, id, otherInfo, callback) {
      var request = searchPerson.endpoint + "/" + apiField + id;
      if (otherInfo.length > 0) {
        request = request + otherInfo;
      }
       //console.log("Requesting: " + request);
      $.ajax({
        type: "GET",
        //beforeSend: function (req)
        //{
        //  req.setRequestHeader("X-access-token", '');
        //},
        url: request,
        async: syncflag,
        success: function (data) {
          //console.log("response for: " + request);
          // console.log(data);
          callback(data);
        },
        error: function (fail) {
          console.error(fail);
        }
      });
    };

    return this;
  });
  /* Return constructed bus */
  return link;

})();

No comments:

Post a Comment