html [freshdesk jquery] #customer

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html [freshdesk jquery] #customer相关的知识,希望对你有一定的参考价值。

<!--
Full: https://github.com/freshdesk/fresh-samples/tree/master/jquery
  create_ticket.html
  create_ticket_with_attachment.html
  edit_ticket.html
  fetch_tickets.html
-->
<!-- create ticket example: -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(
      function() {
        var yourdomain = 'yourdomain'; // Your freshdesk domain name. Ex., yourcompany
        var api_key = 'API_KEY'; // Ref: https://support.freshdesk.com/support/solutions/articles/215517-how-to-find-your-api-key
        ticket_data = '{ "description": "Details about the issue...", "subject": "Support Needed...", "email": "tom@outerspace.com", "priority": 1, "status": 2, "cc_emails": ["ram@freshdesk.com","diana@freshdesk.com"] }';
        $.ajax(
          {
            url: "https://"+yourdomain+".freshdesk.com/api/v2/tickets",
            type: 'POST',
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            headers: {
              "Authorization": "Basic " + btoa(api_key + ":x")
            },
            data: ticket_data,
            success: function(data, textStatus, jqXHR) {
              $('#result').text('Success');
              $('#code').text(jqXHR.status);
              $('#response').html(JSON.stringify(data, null, "<br/>"));
            },
            error: function(jqXHR, tranStatus) {
              $('#result').text('Error');
              $('#code').text(jqXHR.status);
              x_request_id = jqXHR.getResponseHeader('X-Request-Id');
              response_text = jqXHR.responseText;
              $('#response').html(" Error Message : <b style='color: red'>"+response_text+"</b>.<br/> Your X-Request-Id is : <b>" + x_request_id + "</b>. Please contact support@freshdesk.com with this id for more information.");
            }
          }
        );
      }
    );
});
</script>

<button>Create ticket</button>
<br/>
<table cellspacing = '10'>
  <tr>
    <td> <b>Result</b></td>
    <td> <div id = 'result'></div> </td>
  </tr>
  <tr>
    <td> <b>Code</b></td>
    <td> <div id = 'code'></div> </td>
  </tr>
  <tr>
    <td> <b>Response</b></td>
    <td> <div id = 'response'></div> </td>
  </tr>
</table>

以上是关于html [freshdesk jquery] #customer的主要内容,如果未能解决你的问题,请参考以下文章

php [freshdesk php core] freshdesk php api #customer

使用 Swift 2.2 中的 Freshdesk API

javascript [freshdesk节点] #customer

从 SQL Server 触发器调用 Freshdesk API

php [freshdesk php]客户服务#customer

python [freshdesk - python]客户服务#customer