weixin_33714884 2018-02-14 10:19 采纳率: 0%
浏览 44

Ajax发布到完整日历

I am working on adding events to the full calendar which is intern connected to google calendar via ajax post, but the result isn't successful, though i do not get any errors, but the get call and the delete is successful(here i mean to say that the delete, deletes an event from my GCAL and the Get gets all events from my Gcal) this is my HTML and JS file

Could anyone please guide here Thanks in advance

 jQuery(document).ready(function() {

        //CalendarGoogle.init();

        $('#add_event_submit').click(function(){
            var title = $('#title').val();
            var start = $('#start').val();
            var end = $('#end').val();
            alert(title+" "+start);


            function send() {
                var data = {
                    summary: $("#title").val(),
                    start:$("#start").val(),
                    end:$("#end").val()
                }

                $('#target').html('sending..');

                $.ajax({
                    url: 'https://www.googleapis.com/calendar/v3/calendars/subhanu.com_7ejfdkhes1vhgommacqo86l85k@group.calendar.google.com/events?access_token=xxxxxxxxxxxxx',
                    type: 'post',
                    dataType: 'json',
                    success: function (data) {
                       console.log(data);
                    },
                    data: events
                });
            }
            });

        });
<form role="form" name="add_event_form">
    <div class="form-group">
        <label>Event Name: </label>
        <input class="form-control" name="title" id="title"placeholder="Customer">
    </div>

    <div class="form-group">
        <label>Start: </label>
        <input class="form-control" type="datetime-local" name="start" id="start" placeholder="">
    </div>

    <div class="form-group">
        <label>End: </label>
        <input class="form-control" type="datetime-local" name="end" id="end" placeholder="">
    </div>


    <div class="form-group">
        <button class="btn btn-default" type="submit" id="add_event_submit">
            <i class="fa fa-floppy-o"></i>
            Add Event</button>
    </div>
</form>

</div>
  • 写回答

1条回答 默认 最新

  • weixin_33688840 2018-02-14 11:02
    关注

    I have tried to fix a few things:

    Firstly : You don't need a function inside the event, The function is only getting registered and not getting called.

    function send() {
    

    Secondly: data: events here events is not declared

    the source code after making the change is as follows:

    jQuery(document).ready(function() {
    
        //CalendarGoogle.init();
    
        $('#add_event_submit').click(function(){
            var title = $('#title').val();
            var start = $('#start').val();
            var end = $('#end').val();
            console.log(title+" "+start);
    
            var data = {
                    summary: $("#title").val(),
                    start:$("#start").val(),
                    end:$("#end").val()
                }
              console.log(data);
    
                $.ajax({
                    url: 'https://www.googleapis.com/calendar/v3/calendars/subhanu.com_7ejfdkhes1vhgommacqo86l85k@group.calendar.google.com/events?access_token=xxxxxxxxxxxxx',
                    type: 'post',
                    dataType: 'json',
                    success: function (data) {
                       console.log("success");
                       console.log(data);
                    },
                    data: data
                }).always(function()
                       {
                  console.log("done");
                });
    
            });
    
        });
    

    Codepen for reference: https://codepen.io/YasirKamdar/pen/BYdMJE

    评论

报告相同问题?

悬赏问题

  • ¥15 Coze智能助手搭建过程中的问题请教
  • ¥15 12864只亮屏 不显示汉字
  • ¥20 三极管1000倍放大电路
  • ¥15 vscode报错如何解决
  • ¥15 前端vue CryptoJS Aes CBC加密后端java解密
  • ¥15 python随机森林对两个excel表格读取,shap报错
  • ¥15 基于STM32心率血氧监测(OLED显示)相关代码运行成功后烧录成功OLED显示屏不显示的原因是什么
  • ¥100 X轴为分离变量(因子变量),如何控制X轴每个分类变量的长度。
  • ¥30 求给定范围的全体素数p的(p-2)/p的连乘积值
  • ¥15 VFP如何使用阿里TTS实现文字转语音?