weixin_33734785 2016-04-27 08:50 采纳率: 0%
浏览 7

加载后的ajax请求

I have some problems with Ajax and .load; I want to fire the ajax request under three circumstances. When a facility is chosen and when the preMonth/nextMonth was chosen.

My problem is that Ajax doesn't send the dates of the new month but the last active Month.

jQuery('main').on('click', '#terminstandorte select option, .nextMonth, .prevMonth', function(){

    //Some Code

    if (jQuery(this).get(0) == jQuery('.nextMonth').get(0)) {
        jQuery('#kalender').load('?' + jQuery(this).attr('value') + ' #thisMonth',function () {
            getFreeDates();
        });
    } else if (jQuery(this).get(0) == jQuery('.prevMonth').get(0)) {
        jQuery('#kalender').load('?' + jQuery(this).attr('value') + ' #thisMonth',function () {
            getFreeDates();
        });
    }

    var werk = parseInt(jQuery('#terminstandorte select option:selected').attr('value'));
    var firstDay = jQuery('.calDates .noDate:first').attr('id');
    var lastDay = jQuery('.calDates .noDate:last').attr('id');

    //Some Code again


    function getFreeDates() {
        //Hier werden alle freien Termine für den aktuellen Monat angezeigt
        jQuery.ajax({
            url: CENSORED,
            type: "GET",
            data: {
                request: request,
                werk: werk,
                firstDay: firstDay,
                lastDay: lastDay
            },
            contentType: 'application/json; charset=utf-8',
            beforeSend: function () {
                // console.log(firstDay, lastDay);
                today = new Date(firstDay);
                console.log(today.getMonth()+1);
            },
            success: function (data) {
                freeDates = JSON.parse(data);
                freeDates.forEach(function (date) {
                });
            },
            error: function () {
                alert('Etwas lief schief');
            }
        })
    }
});

I tried to put the Ajax in a function, so that Ajax is called after the load, but the result is still the same.

What I am doing wrong?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 Jenkins自动化部署—悬赏100元
    • ¥15 关于#python#的问题:求帮写python代码
    • ¥20 MATLAB画图图形出现上下震荡的线条
    • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
    • ¥15 perl MISA分析p3_in脚本出错
    • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
    • ¥15 ubuntu虚拟机打包apk错误
    • ¥199 rust编程架构设计的方案 有偿
    • ¥15 回答4f系统的像差计算
    • ¥15 java如何提取出pdf里的文字?