Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. jQuery(document).ready(function($) {
  2. // Pull 10 Accounts via the REST API
  3. $.ajax('/services/data/v28.0/query?q=SELECT+Name+FROM+Account+LIMIT+10',
  4. {
  5. beforeSend: function(xhr) {
  6. // Set the OAuth header from the session ID
  7. xhr.setRequestHeader('Authorization', 'Bearer {!$Api.Session_ID}');
  8. xhr.setRequestHeader('batchSize', '5');
  9. },
  10. success: function(response) {
  11. // We got 'em - append our records to the HTML list
  12. $.each(response.records, function(index, record) {
  13. $('#accountList').append('<li>'+record.Name+'</li>');
  14. });
  15. },
  16. error: function(jqXHR, textStatus, errorThrown) {
  17. // Oops - what went wrong?
  18. alert(jqXHR.status + ': ' + errorThrown);
  19. }
  20. }
  21. );
  22. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement