Skip to main content

Jquery call

  • July 9, 2016
  • 1 reply
  • 103 views

 Hi. How i can make a jquery call?

For example, that code dont work:


$.ajax({
cache: false,
url: 'http://www.example.com/example.php',
type: 'GET',
dataType: 'text',
success: function(text){
    alert(text);
}
});



Is possible make that work?

Did this topic help you find an answer to your question?
This topic has been closed for comments

1 reply

Example app:

 

<script>
  jQuery(document).on('sidebar_loaded', function() {

    var service_user = 'someusername';
    var service_pass = 'somepassword';
    var auth_head = "Basic " + btoa(service_user + ":" + service_pass);
    var proxy_bundle = {
      domain: 'https://somedomain.com',
      ssl_enabled: true,
      auth_type: "Basic",
      username: service_user,
      password: service_pass
    };

    var exampleApp = {

      init: function() {
        console.log("------------ init ------------");
        this.requestGetEntity('15467');
        return this;
      },

      requestGetEntity: function(entity_id) {
        console.log("------------ requestGetEntity ------------");
        var temp = '/entities/' + entity_id + '.json';
        var this_object = this;
        var service_request = {
          method: "get",
          body: "",
          rest_url: temp,
          headers: {
            "Authorization": auth_head
          },
          on_success: function(data) {
            this_object.printResult(data.responseJSON);
          },
          on_failure: function(data) {
            console.log("FAILURE (requestGetEntity) data.responseJSON:");
            console.log(data.responseJSON);
          }
        };
        var proxy = new Freshdesk.Widget(proxy_bundle);
        proxy.request(service_request);
      },

      printResult: function(data) {
        console.log("------------ printResult ------------");
        console.log("Result:");
        console.log(data);
      }

    };

    var obj = exampleApp.init();

  });
</script>

 

: