0

Hello Everybody,

I have a problem with including a .php file into a javascript code. This is a calendar, and I want the calendar to use my database data. So here is my code of the javascript:

<script type='text/javascript'>

    $(document).ready(function() {
        var date = new Date();
        var d = date.getDate();
        var m = date.getMonth();
        var y = date.getFullYear();

        $('#calendar').fullCalendar({
            header: {
                left: 'prev,next today',
                center: 'title',
                right: 'month,agendaWeek,agendaDay'
            },
            editable: true,
            events: "http://.../events.php",
        });

    });

    </script>

As you can see, there is the "events: link" part, where I include my events.php file what shows this if I open:

[{"id":"7","title":"Naspolya utca","start":"2013-10-05T08:30","end":"2013-10-05T08:30","allDay":false}]

So far so good, if I paste this content instead of the http://.../events.php this will work. But with the link I include there, it doesn't. So I think I am doing something wrong with including the link there or sth like that...

I would be really happy if you could help me.

If something is confusing about my explanation, please ask it.

Thanks, Tibor

Edited by deceptikon: Moved to Javascript. Please post in the correct forum next time.

3
Contributors
3
Replies
18
Views
4 Years
Discussion Span
Last Post by ryantroop
0

This is a calendar, and I want the calendar to use my database data.

@tibormarias

Where did you get this code?

Is this datepicker? or something other calendar code?

0

This script is called fullcalendar. This is free jquery script I think.

0

just because you output JSON from your PHP code it does not mean the variable will automagically evaluate to JSON Object notation. It is, as far as I know, still just a string. It needs to be parsed or evaled.

You can, before loading, run an AJAX script and eval or JSON.parse() into a variable the array of objects you are expecting, then let events: yourvar, ....

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.