kshitizmittal
9 months ago

JSON with Date object

Posted 9 months ago by kshitizmittal
function onChartClick(e){
        jQuery.ajax({
            url: "./pipsubchart",
            type: "GET",
            data: {
                _token: '{{csrf_token()}}',
                pip_type: e.dataPoint.name,
                currMonth: jQuery("#chartMonth").val(),
                currYear: jQuery("#chartYear").val()
            },
            success: function(data) {
                data.forEach(function(value) {
                    value.x = new Date(value.x);
                });
                document.getElementById("result").innerHTML = JSON.stringify(data);
            }
        });
    }

I am passiing this above JSON in canvas JS charts datapoints but, it asks for date object as a input value,

My concern is i have already converted the date value into object but when i used JSON.stringify() It again changed the value to string.

Please sign in or create an account to participate in this conversation.