Ajax返回整个HTML页面

时间:2014-12-17 18:46:37

标签: php jquery ajax

这是围绕互联网的常见问题,但没有解决方案对我有用。每当我添加dataType时都会出错:' json'。我也尝试过以这种形式提供数据" date = 2014-12-15"并省略了数据类型。我尝试以多种方式格式化我的JSON。我想要做的是将日期发送到PHP页面,然后将$ datalisting字符串返回到ajax页面。但似乎无论我做什么,每当我获得成功,它都会返回带有ajax的页面中的所有HTML。 ..quite难倒在这里。

$(".upcoming-event-dates").click(function(e){
  var date = {"date": "2014-12-15"};
  e.preventDefault();
     $.ajax({
     type: "POST",
     data: date,
     contentType: "application/json; charset=utf-8",
     dataType: "json",
     url: '<?php bloginfo('template_directory'); ?>/date-process.php',
     cache: false,
     success: function (data) {
         alert(data);
         },
     error: function(xhr, ajaxOptions, thrownError){
     alert("cheese helmet");
     },
     timeout : 15000
     });
});

和php代码

require $_SERVER['DOCUMENT_ROOT'].'/wp-load.php' );
$start = $_POST['date'];

$dataListing = "do_shortcode('[events_list_grouped mode='weekly' scope='".$start.",".$start."'                limit='5']</div>

                      <div class='home-calendar-right'>
                      <div class='home-calendar-time-title'>#_EVENTTIMES #_EVENTLINK[/events_list_grouped]')";
                      echo $datedListing; 

0 个答案:

没有答案
相关问题