SQLite-Request后没有回调 [英] No Callback after SQLite-Request

查看:91
本文介绍了SQLite-Request后没有回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

真棒插件。
但我试图通过SQL-Rquest加载一些事件。
请求成功,我可以将数组放在另一个容器中或提醒他们,但日历不会加载事件。这里我的脚本

 
$('#calendar')。fullCalendar(
{
header:{
left:'prev,next today',
center:'title',
right:'month,agendaweek,agendaDay'
},
editable:true,
事件:函数(开始,结束,回调)
{
var rs = db.execute(select * from xCal);
var i = 0;
var events ='[';
while(rs.isValidRow())
{
if(i == 0){var events = events} else {events = events +','}
events = events +
{id:'+ rs.fieldByName('id')+',+
title:'+ rs.fieldByName('title')+',+
allDay:'+ rs.fieldByName('allDay')+',+
start :''+ rs.fieldByName('start')+',+
end:'+ rs.fieldByName('end')+',+
url:' + rs.fieldByName('url')+',+
description:'+ rs.fieldByName('description')+'};
i ++;
rs.next();
}
events = events +']';
回调(事件);

}

});

更新引起的评论.....



感谢您的重播,但那不是原因。我改变了代码(删除引号和url完成),但它没有运行:(。

如果我尝试在事件中放回SQL请求();。

我已经提醒了回调-v。

 函数(事件){
回调(事件);
popLoading();
}

调用回调本身?



更新原因回答....

请参阅上文。相信我,字符串是正确的。顺便说一下,我使用的是Unix时间戳;)

解决方案

因此,如果您使用

  events:function(start,end,callback){} 

使您的事件必须创建jscript数组.. ..不是json类型的字符串。 p>

所以作为一个基本和简单的例子可行。

  events:function (开始,结束,回调)
{
var event = [];
event.push({
title:'Garten',
start:'2011-05-10T00:00:00',
allday:true
}) ;

回调(事件);

$ / code>

就像这个例子所显示的那样



http://jsfiddle.net/ppumkin/6wE8v/



你只需要插入你的数据库的东西。道歉混乱的评论



所以有点你的代码:

  id:rs.fieldByName('id'),
title:rs.fieldByName('title'),
start:rs.fieldByName('start'),
等。


awesome plugin. But I tried to load some events via SQL-Rquest. The Request is successfully, I can put the Array in another Container or alert them, but the Calendar wouldnt load the events. Here my Script

        $('#calendar').fullCalendar(
            {
             header: {
                    left: 'prev,next today',
                    center: 'title',
                    right: 'month,agendaWeek,agendaDay'
                    },
             editable: true,        
             events: function(start, end, callback)
                        {
                        var rs = db.execute("select * from xCal");
                        var i = 0;
                        var events = '[';
                        while(rs.isValidRow()) 
                            {                       
                            if(i == 0){var events=events}else{events = events+','}
                            events=events+
                                        "{id:'"+rs.fieldByName('id')+"',"+
                                        "title:'"+rs.fieldByName('title')+"',"+
                                        "allDay:'"+rs.fieldByName('allDay')+"',"+
                                        "start:'"+rs.fieldByName('start')+"',"+
                                        "end:'"+rs.fieldByName('end')+"',"+
                                        "url:'"+rs.fieldByName('url')+"',"+
                                        "description:'"+rs.fieldByName('description')+"'}";
                            i++;
                            rs.next(); 
                            }
                        events = events+']';
                        callback( events );

                        }

            }); 

Udate cause comments .....

Thanks for replaying, but thats not the reason. I changed the code (removed quotes and the url complete), but it´s not running :( .

If I try to put the return of SQL request in the event-option, its runnig perfect. It seems, I have a problem with the callback();.

I have alerted the callback-var.

function(events){
            callback(events);
            popLoading();
            }

Calls callback itself?

Update cause answer ....

See above. Believe me, the string is correct. BTW I´m using Unix timestamp ;)

解决方案

So if you use

 events: function(start, end, callback) { }

to make your events you have to create a jscript array .. not a json type string.

So as a basic and simple example that works.

events:function(start,end,callback)
        {
            var event = [];
            event.push({
                title: 'Garten',
                start: '2011-05-10T00:00:00',
                allday: true
            });

            callback(event);
        }

On it works as this example shows

http://jsfiddle.net/ppumkin/6wE8v/

You just need to plug your db stuff in. Apologies for the confusion in the comments

so a bit of your code:

id: rs.fieldByName('id'),
title: rs.fieldByName('title'),
start: rs.fieldByName('start'),
etc..

这篇关于SQLite-Request后没有回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆