How to Load Ajax in Wordpress

后端 未结 6 1922
失恋的感觉
失恋的感觉 2020-12-02 13:52

I\'m familiar with using ajax in the ordinary way with jQuery.
I\'ve played around it for a while, but don\'t understand what Wordpress needs to get it to work...
Wh

6条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-02 14:11

    Firstly, you should read this page thoroughly http://codex.wordpress.org/AJAX_in_Plugins

    Secondly, ajax_script is not defined so you should change to: url: ajaxurl. I don't see your function1() in the above code but you might already define it in other file.

    And finally, learn how to debug ajax call using Firebug, network and console tab will be your friends. On the PHP side, print_r() or var_dump() will be your friends.

提交回复
热议问题