发布变量没有被jQuery Ajax请求传递?

时间:2016-03-10 02:07:17

标签: javascript php jquery ajax

所以我要做的是使用完整的日历ajax调用来获取在数据库中注册的事件。 当我尝试这样做时,没有弹出错误,事实上,ajax调用会返回成功添加到数据库。

我分别测试了PDO查询并且它工作正常,所以请帮助我使用ajax帖子,因为这是我将错误列为错误的。

这是default.html中的ajax调用。

print(['%.02f' % x for x in priceList])

这是add_events.php(请注意,除了没有收到帖子之外没有错误。)

selectable: true,
selectHelper: true,
select: function(start, end, allDay) {
    var title = prompt('Event Title:');
    var url = prompt('Type Event url, if exits:');
    if (title) {
         var start = $.fullCalendar.moment(start);
         var end = $.fullCalendar.moment(end);
         console.log("Event Triggered");
         $.ajax({
                 url: 'add_events.php',
                 data: 'title='+ title+'&start='+ start +'&end='+ end +'&url='+ url ,
                 type: "POST",
                success: function(json) {
                    alert('Added Successfully');
                 },
                error: function(xhr, textStatus, errorThrown) {
                     alert(xhr.responseText);
                }
         });
        calendar.fullCalendar('renderEvent',
        {
             title: title,
             start: start,
             end: end,
             url:url,
             allDay: allDay
        },
            true // make the event "stick"
        );
    }
    calendar.fullCalendar('unselect');
}

我在控制台日志中看到带有post变量的xhr GET请求。他们只是没有从jQuery转到php。

如何实现这一目标将不胜感激。

enter image description here

1 个答案:

答案 0 :(得分:-1)

使用

data: { title : title, start : start , end : end , url : url } 

而不是

data: 'title='+ title+'&start='+ start +'&end='+ end +'&url='+ url   
相关问题