douxing1850 2014-11-30 12:35
浏览 61

WordPress - Ajax成功函数给出空响应

I have this script:

        <script type="text/javascript">
            jQuery(document).on("click",".pending-post-approve-link",function(e){

                jQuery('#review_post_status').val('approve');

                var globalVar = jQuery(this).find('.review_post_id').val();
                jQuery('#review_post_current_id').val(globalVar);

                jQuery('#post-preloader-'+globalVar).fadeIn(500);

                $.fn.wpjobusSubmitFormFunction();

            });

            $.fn.wpjobusSubmitFormFunction = function() {

                var globalVar = jQuery('#review_post_current_id').val();

                jQuery('#wpjobus-pending-posts').ajaxSubmit
                ({
                    url: '<?php echo admin_url('admin-ajax.php'); ?>',   
                    data: jQuery('#wpjobus-pending-posts').serialize(),
                    type: "POST",
                    success: function(response)
                    {
                        jQuery('#post-preloader-'+response).fadeOut(100);
                        jQuery('#post-'+response).fadeOut(100, function()
                        {
                            jQuery(this).css('display', 'none');
                        });
                        return false;
                    }
                });
            }

        });

        </script>

When this script runs, it gives me empty response. I don't know what causing this problem. This is happening in the success function of the ajax success: function(response). Any help would be appreciated.

  • 写回答

1条回答 默认 最新

  • dqoag62688 2014-11-30 13:07
    关注

    You might have done some of those steps, but myself I would take this approach to find the issues:

    • Use a tool such as Google Chrome console or Firebug for FF to check if your request is being sent to the expected url, and that it is getting an expected response.
    • If it is not getting the expected response, the issue is serverside and you should look there. You can also make some breakpoint using the same tools (console/firebug) to see if the parameters which you are passing look as expected (you can check the POST header details instead too).
    • Finally you can try placing a breakpoint on the success function to be sure that it gets executed at all and that the response is an empty string, and not something else.

    I hope this helps.

    评论

报告相同问题?

悬赏问题

  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 关于#python#的问题:自动化测试