未捕获的TypeError:无法使用“in”运算符在null中搜索“SUPPORT_COOKIES” [英] Uncaught TypeError: Cannot use 'in' operator to search for 'SUPPORT_COOKIES' in null

查看:380
本文介绍了未捕获的TypeError:无法使用“in”运算符在null中搜索“SUPPORT_COOKIES”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用IBM Worklight Developer Edition 5.0.5尝试创建简单(HTML和适配器)应用程序,但面临未解决的问题。

I am using IBM Worklight Developer Edition 5.0.5 to try to create simple(HTML and Adapter) application, but facing unresolved problem.

这可能是相同的在旧论坛中没有回答的问题:
http:// www.ibm.com/developerworks/forums/thread.jspa?threadID=460738

This could be a same problem which is not answered in old forum: http://www.ibm.com/developerworks/forums/thread.jspa?threadID=460738

[环境]
操作系统:Windows7 64位(日语语言环境),
Eclipse:4.2.1,
Worklight:Developer Edition 5.0.5

[Environment] OS: Windows7 64bit(Japanese locale), Eclipse: 4.2.1, Worklight: Developer Edition 5.0.5

[描述]
我在Eclipse中创建了Worklight Project,没有任何外部库,如jQuery mobile和Dojo。我在此项目中添加了HTTP适配器和SQL适配器。当我尝试Run As .. - > Invoke Worklight Procedure时,两者似乎都工作正常。两者都返回了预期的JSON。所以我认为适配器不会出现问题。

[Description] I created Worklight Project in my Eclipse, without any external libraries like jQuery mobile nor Dojo. I added HTTP Adapters and SQL Adapters into this Project. Both seems to work fine when I try 'Run As .. -> Invoke Worklight Procedure'. Both returned expected JSON. So I don't think there would be a problem in Adapters.

但是当我从HTML文件调用这些适配器时,我得到了Uncaught TypeError:无法使用'in'运算符在worklight.js(行:2380)中搜索'SUPPORT_COOKIES'为空错误。

But when I call those adapters from HTML file, I got "Uncaught TypeError: Cannot use 'in' operator to search for 'SUPPORT_COOKIES' in null" error in worklight.js(line:2380).

[我的代码]


var invocationData = {adapter:'SQLAdapter',procedure:
'getCount',参数:[] };

var invocationData = { adapter : 'SQLAdapter', procedure : 'getCount', parameters : [] };

WL.Logger.debug(1:invocationData =+ invocationData);

WL.Client.invokeProcedure(invocationData,{onSuccess :
loadFeedsSuccess,onFailure:loadFeedsFailure});

WL.Logger.debug( "1: invocationData = " + invocationData );
WL.Client.invokeProcedure( invocationData, { onSuccess: loadFeedsSuccess, onFailure: loadFeedsFailure });

WL.Logger.debug(2:loadFeeds);

WL.Logger.debug( "2: loadFeeds" );

function loadFeedsSuccess(result){WL.Logger.debug(3:success:
result =+ result); }

function loadFeedsSuccess( result ){ WL.Logger.debug( "3: success: result = " + result ); }

function loadFeedsFailure(result){WL.Logger.debug(4:failure:
result =+ result); }

function loadFeedsFailure( result ){ WL.Logger.debug( "4: failure: result = " + result ); }

[我的调试控制台输出]

1:invocationData = [object Object] worklight.js:1112

1: invocationData = [object Object] worklight.js:1112

未捕获TypeError:无法使用'in'运算符搜索
'UPPORT_COOKIES'在null worklight.js:2380

Uncaught TypeError: Cannot use 'in' operator to search for 'SUPPORT_COOKIES' in null worklight.js:2380

wlclient init启动worklight.js:1112

wlclient init started worklight.js:1112

之前:app init onSuccess worklight.js:1112

before: app init onSuccess worklight.js:1112

之后:app init onSuccess worklight.js:1112

after: app init onSuccess worklight.js:1112

wlclient init成功

wlclient init success

因此,似乎只有第一个WL.Logger.debug()成功调用,但WL.Client.invokeProcedure( )似乎导致上面的 Uncaught TypeError ,它只是失败了(不是调用成功案例回调,也不是故障案例回调)。

So it seems only first WL.Logger.debug() is called successfully, but WL.Client.invokeProcedure() seems to cause above Uncaught TypeError, and it just failed(not call success-case callback, nor failure-case callback).

这个是一个SQL Adapter案例,但是当我尝试使用HTTP Adapter时,结果是相同的(在WL.Client.invokeProcedure()中失败)。同样,当我尝试'Run As .. - > Invoke Worklight Procedure'时,两者都返回适当的结果。

This is a SQL Adapter case, but when I tryed to use HTTP Adapter, the result was same(failed in WL.Client.invokeProcedure()). Again, both returns appropriate result when I try 'Run As .. -> Invoke Worklight Procedure'.

我的控制台说这个失败发生在worklight.js的第2380行:

My console says this failure happens in line 2380 of worklight.js:


2379:isEnabled:function(field){

2379: isEnabled : function(field) {

2380:返回! !(简介中的字段&& profile [field]);

2380: return !!(field in profile && profile[field]);

2381:}

所以我不知道会出现什么问题用我的代码。这个问题有什么想法/信息吗?感谢您提前。

So I have no idea what would be wrong with my code. Are there any idea/information for this problem? Thanks for advance.

已添加
Mac OSX环境中也发生了同样的错误。

Added Same error was happened in Mac OSX environment too.

推荐答案

我找到了导致我问题的原因。

I have found what caused my problem.

访问适配器时,我在HTML中编辑了我的javascript直接使用< script>文件标签位于autogenerated< script>的最底部标签,并试图创建初始页面。我认为这不适合Worklight。我不确定到底出了什么问题,但我的javascript代码可以在所有准备好之前加载。

When accessing adapter, I edited my javascript inside of HTML file directly, using <script> tag at very bottom of autogenerated <script> tags, and tried to create initial page. I believe that is not appropriate way for Worklight. I am not sure what was wrong exactly, but my javascript code could be loaded before everything prepared.

现在我改变了我的代码。 我将我的javascript(曾经是HTML内部)移动到(Projectname).js 中wlCommonInit()函数的最底层。目前它似乎工作正常,没有像以前那样的错误消息,并通过适配器检索预期的信息。这可能是一种合适的方式。

Now I changed my code. I moved my javascript, which used to be inside of HTML, to very bottom of wlCommonInit() function in (Projectname).js. Currently it seems to work fine with no error message like before, and retrieves expected information via adapter. This might be an appropriate way.

这篇关于未捕获的TypeError:无法使用“in”运算符在null中搜索“SUPPORT_COOKIES”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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