Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Proste zapytanie Ajax w Wordpressie, Dlaczego nie działa?
AboutMe
post 30.05.2018, 15:03:11
Post #1





Grupa: Zarejestrowani
Postów: 261
Pomógł: 0
Dołączył: 24.02.2008

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


Dzień dobry,

Czy wiecie może dlaczego poniższy kod nie działa? Za każdym razem zwraca fail. Konsola -> https://pastebin.com/TABQCjXe

  1. jQuery(document).ready(function($) {
  2.  
  3. // This does the ajax request
  4. $.ajax({
  5. type: 'post',
  6. url: ajaxurl,
  7. data: {
  8. 'action':'prefix_load_cat_posts'
  9. },
  10. success:function(data) {
  11. // This outputs the result of the ajax request
  12. console.log(data);
  13. $( ".prefix_load_cat_posts" ).append("success");
  14. },
  15. error: function(errorThrown){
  16. console.log(errorThrown);
  17. $( ".prefix_load_cat_posts" ).append("fail");
  18. }
  19. });
  20.  
  21. });


PHP -> https://pastebin.com/g4QiWDky
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
AboutMe
post 30.05.2018, 15:47:55
Post #2





Grupa: Zarejestrowani
Postów: 261
Pomógł: 0
Dołączył: 24.02.2008

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


Znalazłem źródło problemu, trzeba użyć

  1. 'action':'load-filter'


zamiast

  1. 'action':'prefix_load_cat_posts'


Ten post edytował AboutMe 30.05.2018, 15:48:40
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 Wersja Lo-Fi Aktualny czas: 26.04.2024 - 06:41