Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Funkcja zwraca Undefinied
topcio
post 20.04.2023, 05:19:59
Post #1





Grupa: Zarejestrowani
Postów: 140
Pomógł: 0
Dołączył: 14.01.2017

Ostrzeżenie: (0%)
-----


Witam

Prośba o pomoc, co robię nie tak, że funkcja zwraca mi UNDEFINIED

  1.  
  2. document.addEventListener('DOMContentLoaded', (event) => {
  3.  
  4. const equipmentHelmet = document.querySelectorAll('.equipment_helmet');
  5.  
  6. function all() {
  7. $.ajax({
  8. type: "GET",
  9. url: './form/eq_helmet.php',
  10. success: function (response) {
  11. response = JSON.parse(response);
  12. if(response.length) {
  13. console.log(response);
  14. return {
  15. buttons: {
  16. Spam: ({
  17. text: ' ',
  18. backgroundColor: 'transparent',
  19. buttonWithImage: true,
  20. imageFrame: 'url(/images/equipment/EQ_Common.webp)',
  21.  
  22. imageOptURL: 'url(/images/equipment/ACCESSORY_Ambrosial_Cup.webp)',
  23. imageOptSize: 'cover',
  24. imageOptPosition: 'center',
  25. imageOptRepeat: 'no-repeat',
  26.  
  27. imageWidth: '80px',
  28. imageHeight: '80px',
  29.  
  30. action: function(){
  31.  
  32. }
  33. })
  34. }
  35.  
  36. }
  37. }
  38. }
  39. });
  40. }
  41.  
  42. equipmentHelmet.forEach(div => {
  43. div.addEventListener('click', function() {
  44. $.confirm({
  45. content: '',
  46. title: 'Zmień Budynek',
  47. closeIcon: true,
  48. action: console.log(all()),
  49. });
  50. });
  51. });
  52. });


Ten post edytował topcio 20.04.2023, 05:20:21
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
topcio
post 20.04.2023, 10:24:39
Post #2





Grupa: Zarejestrowani
Postów: 140
Pomógł: 0
Dołączył: 14.01.2017

Ostrzeżenie: (0%)
-----


Wydaje mi się, że wszystko OK, jeśli coś nie tak dajcie znać

  1. document.addEventListener('DOMContentLoaded', (event) => {
  2.  
  3. const equipmentHelmet = document.querySelectorAll('.equipment_helmet');
  4.  
  5. function helmet(rodzaj, nazwaPL) {
  6. return new Promise(() => {
  7. $.ajax({
  8. type: "GET",
  9. url: './form/eq_helmet.php',
  10. success: function (response) {
  11. response = JSON.parse(response);
  12. if(response.length) {
  13. var name = {};
  14. $.each(response, function() {
  15. name[this['Name']] = {}
  16. name[this['Name']]['text'] = ' ';
  17. name[this['Name']]['backgroundColor'] = 'transparent';
  18. name[this['Name']]['buttonWithImage'] = 'true';
  19. name[this['Name']]['imageFrame'] = 'url(/images/equipment/EQ_Common.webp)';
  20. name[this['Name']]['imageOptURL'] = 'url(/images/equipment/' + rodzaj + '_' + this['Name'] + '.webp)';
  21. name[this['Name']]['imageOptSize'] = 'cover';
  22. name[this['Name']]['imageOptPosition'] = 'center';
  23. name[this['Name']]['imageOptRepeat'] = 'no-repeat';
  24. name[this['Name']]['imageWidth'] = '80px';
  25. name[this['Name']]['imageHeight'] = '80px';
  26. name[this['Name']]['action'] = 'function(){}';
  27. });
  28. result =
  29. $.confirm(
  30. {
  31. content: '',
  32. title: nazwaPL,
  33. closeIcon: true,
  34. buttons: name
  35. }
  36. );
  37. }
  38. }
  39. });
  40. })
  41. }
  42.  
  43. equipmentHelmet.forEach(div => {
  44. div.addEventListener('click', function() {
  45. helmet('HELMET', 'Hełm')
  46. });
  47. });
  48. });
  49.  
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 4.06.2024 - 16:39