Wordpress Create Category AJAX Response

假如想象 提交于 2019-12-10 16:43:40

问题


I currently have a plugin that allows a user to activate/deactivate categories to drive a menu. I've created an option for the toggle and have it functioning in the create form and edit form seamlessly. The only place I can't seem to add it is to the AJAX return from wordpress when the category is created. I can create the column when the Categories page is loaded but don't know how to tap into the AJAX Return without modifying the core. Is there a hook that I'm unaware of that allows you to modify this return?


回答1:


Do you try to run some Javascript after ajax return (after add new category)?

Try to put below code in your code when you create the custom field in category form :

       $(document).ajaxComplete(function(event, xhr, settings) {

         var queryStringArr = settings.data.split('&');

         if ($.inArray('action=add-tag', queryStringArr) !== -1){
             your_javascript_function(); //this is your js function
         }

       });



回答2:


Using Akmal's answer, this is my script to check if the Taxonomy-Category was created or not. Thanks Akmal.

Wordpress version 3.8.2

        $(document).ajaxComplete(function(event, xhr, settings) {
            var queryStringArr = settings.data.split('&');
                if( $.inArray('action=add-tag', queryStringArr) !== -1){
                    var xml = xhr.responseXML;
                    $response = $(xml).find('term_id').text();
                    if($response!=""){
                        console.log('This is the action.');

                    }
                }
        });


来源:https://stackoverflow.com/questions/15281995/wordpress-create-category-ajax-response

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!