jquery week calendar and db

142 views
Skip to first unread message

Junior

unread,
Apr 9, 2010, 10:43:02 PM4/9/10
to jquery week calendar
Hello everybody,

I'm trying to integrate jquery calendar week with my database for it
to load all the events to be started, but I can not.

Following codes:

demo.js:
data : function(start, end, callback) {

var cliente = $("#idCli").val();

$.getJSON("searchAgenda", {
idCli:cliente
}, function(result) {
alert(result);
callback(result);
}

);


}


searchAgenda (php file):
...
$arr[]=array(
'id' => $ln["id_agenda"],
'title'=> $ln["nm_agenda"],
'start'=> date("c", strtotime($ln["start"])),
'end' => date("c", strtotime($ln["end"]))
);

}

echo json_encode($arr);
...

This returns something like:
[{"ïd":"1","title":"teste","start":"2010-04-08T10:00:00-03:00",
"end":"2010-04-08T11:30:00-03:00"}]

When I call $. post () instead of $. GetJSON is returned an error
"Error: 'length' is null or not an object" and when I call $. GetJSON
is not displayed a error message and also does not show the alert
(result).

Sorry for my bad English.

Thanks in advance

MoUeTtE

unread,
Apr 22, 2010, 2:52:46 AM4/22/10
to jquery week calendar
Hi,

it might be too late, but it could help others:`

first thing to do in the case the JSON isn't understood by
weekCalendar, is to validate the response. (use http://www.jslint.com/
to do that.)

if you want to have an error message on json format error, use
jQuery.ajax({ type: json, /*... */}) with onerror callback.
Same thing to request with post, or use the $.jsonParse function to
parse raw text response.

if there is still an issue, come back, we'll check it together.

Julien.
--
Subscription settings: http://groups.google.com/group/jquery-week-calendar/subscribe?hl=en

Junior

unread,
Apr 22, 2010, 9:10:31 PM4/22/10
to jquery week calendar
Hi Julien,

First I would like to thank the previous answer.

I really enjoyed the site you indicated (JSLint). With him I could see
that the answer was that he was returning an incorrect format.
However, since the adjusted and still are not showing calendar dates.

Is returning this from my DB:
[{"id":
1,"start":"2010-04-08T10:00:00-03:00","end":"2010-04-08T11:30:00-03:00","title":"sdf"},
{"id":
2,"start":"2010-04-08T15:00:00-03:00","end":"2010-04-08T17:00:00-03:00","title":"á
teste 139"}]

$.getJSON("searchAgenda.php",
{idCli:cliente},
function(events){
return events;
}
);

When I have this line "callback (events)" is displayed me an error.
Then I switched to "return events;" that there is no error, but does
not display anything on your calendar.

Sorry for my bad English.

Thanks in advance!

Junior

On Apr 22, 3:52 am, MoUeTtE <the.moue...@gmail.com> wrote:
> Hi,
>
> it might be too late, but it could help others:`
>
> first thing to do in the case the JSON isn't understood by
> weekCalendar, is to validate the response. (usehttp://www.jslint.com/

MoUeTtE

unread,
Apr 23, 2010, 3:51:31 AM4/23/10
to jquery week calendar
Hi junior,

first of all, i'm glad you found the JSON problem, eventhough I
realized I did not give you the right link, I gave you the javascript
linter, not the JSON one !

right adress (for future debug) is http://www.jsonlint.com/

the return approach for the events is definitely not the right one,
you have to use the callback function for sure.

Another thing that could explain this problem, without going further
into the code is libraries versions:

- which version of the plugin do you use (all are 1.2.2 for now, but
there is svn version and git version that are different) ?
- and for jQuery UI, do you use the right one ?

svn version is compatible with jquery 1.3 and UI 1.7, and git last
version is compatible with jQuery 1.4 and 1.8

If the demos are working using your jQuery version (you have to modify
demos or to copy files in order to check), that's definitely not the
problem, but it worth it to check.

next step is trying to log the returned events (using firebug or other
developer tools) and check you get into the callback.

then, if it still doesn't fix your problem, try to follow your events
within the process, and check where it stops.

after all that is done, to go any further I would need an online
example.

good luck !

Julien
Reply all
Reply to author
Forward
0 new messages