Advertisement
Guest User

Untitled

a guest
Nov 24th, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. function attachEvents() {
  2. const appId="kid_rkFRw1QGl";
  3. const user="sa6o88";
  4. const pass="wotan";
  5. const cript=btoa(`${user}:${pass}`);
  6. const header={Authorization:`Basic ${cript}`};
  7. const url='https://baas.kinvey.com/apdata/${appId}/biggestCatches';
  8.  
  9. $('#aside').find('button.load').on('click', function (){
  10. $.ajax({
  11. method: 'GET',
  12. url: url,
  13. headers: header,
  14. contentType: 'application/json'
  15. })
  16. .then(list)
  17. .catch(err);
  18.  
  19.  
  20. })
  21. $('#addForm').find('button.add').on('click', function(){
  22. let angler=$('#addForm','input.angler').val();
  23. let weight=$('#addForm','input.weight').val();
  24. let species=$('#addForm','input.species').val();
  25. let location=$('#addForm','input.location').val();
  26. let bait=$('#addForm','input.bait').val();
  27. let captureTime=$('#addForm','input.captureTime').val();
  28. let obj={
  29. 'angler': angler,
  30. 'weight': weight,
  31. 'species': species,
  32. 'location': location,
  33. 'bait': bait,
  34. 'captureTime': captureTime
  35. };
  36. $.ajax({
  37. method: 'POST',
  38. url: url,
  39. headers: header,
  40. data: JSON.stringify(obj),
  41. contentType: 'application/json'
  42. })
  43. .then(list)
  44. .catch(err);
  45.  
  46. })
  47. function list(){
  48.  
  49.  
  50. }
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement