运行 admin-ajax.php 返回 400

问题描述

我已经查看了其他一些相关问题,但我一定遗漏了一些东西。

我不太了解 PHP,但我希望有人能帮助我告诉我 iv 哪里出错了。 该网站说 /wp-admin/admin-ajax.PHP 返回 400 错误

  • Status400 错误请求
  • 版本HTTP/1.1
  • 转入 616 B(1 B 尺寸)
  • Referrer Policystrict-origin-when-cross-origin

下面的代码 - functions.PHP

    function ajax_submit_abuseform() {
      header( 'Content-type: application/json' );
      // Handle request then generate response using WP_Ajax_Response
      $data = $_POST['data'];
      $postid = $data['postid'];
      $message = 'Post Link: ' . get_post_permalink($postid) 
        . '<br />Reported File: ' . $data['reportedfilepath'] 
        . '<br />Abuse Description: ' . $data['inputabusedetails'];
      $headers = ""; $attachments = "";
      $subject = wp_get_current_user()->user_login . ' reported site abuse: PostID ' . $data['postid'];
      add_filter( 'wp_mail_content_type','set_html_content_type' );
      wp_mail( 'SAMPLE@EMAIL.COM',$subject,$message,$headers,$attachments ); 
      remove_filter( 'wp_mail_content_type','set_html_content_type' );`
            
      $response = array(
        'message'=>$message,'filereported'=>$data['reportedfilepath'],'postid'=>$data['postid'],'data'=>'<p><strong>Hello World!</strong></p>'
      );
      $xmlResponse = new WP_Ajax_Response($response);
      $xmlResponse->send();
      exit();
    }

 function setupcustomajaxscript() {
            $localize = array(
                'ajaxurl' => '/wp-admin/admin-ajax.PHP'
            );
    
      wp_enqueue_script( 'submit_abuseform','/devteamfiles/inc/lightBoxreportlink.js','jquery',true,'1.6');
      wp_localize_script( 'submit_abuseform','my_ajax_script',$localize);
    }



    add_action( 'wp_enqueue_scripts','setupcustomajaxscript' );
        add_action( 'wp_ajax_submit_abuseform','ajax_submit_abuseform' );
add_action( 'wp_ajax_nopriv_submit_abuseform','ajax_submit_abuseform' );

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)