Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Funkcja zwraca Undefinied
topcio
post
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
Post #2





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

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


Ok już poprawiłem i zmieniłem całość

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


Ale mam jeszcze jedno pytanie i prośbę o pomoc bo nie wiem jak to ugryźć

  1.  
  2. Spam: ({
  3. text: ' ',
  4. backgroundColor: 'transparent',
  5. buttonWithImage: true,
  6. imageFrame: 'url(/images/equipment/EQ_Common.webp)',
  7.  
  8. imageOptURL: 'url(/images/equipment/ACCESSORY_Ambrosial_Cup.webp)',
  9. imageOptSize: 'cover',
  10. imageOptPosition: 'center',
  11. imageOptRepeat: 'no-repeat',
  12.  
  13. imageWidth: '80px',
  14. imageHeight: '80px',
  15.  
  16. action: function(){
  17.  
  18. }
  19. })
  20.  
  21.  


w tym miejscu chciałbym zrobić tyle obiektów ile zwraca ajax, teraz dałem jeden ręcznie by zobaczyć czy działa.
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 21.11.2025 - 09:33