在控制台中找不到数据值

时间:2017-03-23 06:59:37

标签: php jquery

 var name = this.value ;
 alert(name);
 $.ajax({
type: "POST",
url: "<?php echo get_site_url(); ?>/wp-content/themes/dt-the7/home.php",
data :name,
success: function(result){
    console.log(result);


    }

我正确获取警报值,但在ajax调用中我没有得到输出。

1 个答案:

答案 0 :(得分:0)

每次看起来你的ajax请求都不成功。尝试添加错误处理:

var name = this.value ;
alert(name);
$.ajax({
  type: "POST",
   url: "<?php echo get_site_url(); ?>/wp-content/themes/dt-the7/home.php",
   data :name,
   success: function(result){
      console.log(result);
   }
  error: function (xhr, ajaxOptions, thrownError) {
    console.log(xhr.status);
    console.log(thrownError);
  }