简体   繁体   English

使用Facebook javascript SDK时出错

[英]Error when using facebook javascript SDK

Hi for some reason when I invoke GET methodes from a simplemodal dialog they fail with the following error: 嗨,由于某些原因,当我从一个简单模式对话框中调用GET方法时,它们失败并显示以下错误:

Uncaught TypeError: Cannot call method 'toLowerCase' of undefined 未捕获的TypeError:无法调用未定义的方法“ toLowerCase”

the error occurs at line 10 in the facebooks all.js. 错误发生在facebook all.js的第10行。 The same methode succeed when called not from the modal dialog. 如果不从模式对话框中调用,则相同的方法将成功。 Also any post method succeed from the modal dialog as well. 同样,任何发布方法也可以从模式对话框中继承。

The method is a trivial one: 该方法很简单:

FB.api(postId,'GET', function(response) {
 alert('hello');
} 

I had the same problem with a delete call like this: 这样的删除呼叫也有同样的问题:

FB.api( id, 'delete', function(response) {
    console.log(response);
});

It turns out the problem was that the id was an integer and not a string. 原来的问题是id是整数而不是字符串。 I got the id from the URL with PHP and cast it to an int and then output it as javascript using json_encode, so I just had to cast it back to a string to solve the problem. 我使用PHP从URL中获取ID,并将其转换为int,然后使用json_encode将其输出为javascript,因此我只需要将其转换为字符串即可解决该问题。 One way to do this with javascript is like this: 用javascript做到这一点的一种方法是这样的:

var int = 10;
console.log( '' + int );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM