Ajax : Why success displays 0?

前端 未结 10 1140
生来不讨喜
生来不讨喜 2021-01-01 19:02

I use ajax with jquery and when I tried to display the result in popup. Then alert always displays 0

success : function(results) { 
alert(result         


        
相关标签:
10条回答
  • 2021-01-01 19:40

    I had a similar issue with admin-ajax.php returning 0, even i had die().

    My problem was that the add_action was declared in a file not loaded default by plugin.

    Anyway, if you have problem also check in browser what __.com/wp-admin/admin-ajax.php?action=youraction returns.

    0 讨论(0)
  • 2021-01-01 19:42

    That's probably because the server side script you are calling with AJAX returns 0 (the one you have specified in the url property).

    0 讨论(0)
  • 2021-01-01 19:44

    Make sure the action_name is ok. If it's not found in functions.php you will get 0 as the result.

    0 讨论(0)
  • 2021-01-01 19:44

    I had the same issue. I'd forgotten to enable the plugin. After enabling the plugin I received the expected data.

    0 讨论(0)
提交回复
热议问题