如何读取ajax对话框的信息
我想使用 javascript&jQuery 开发一个 firefox 扩展,它可以提取用户的 facebook 隐私设置。 在“隐私设置”菜单中,您可以单击“编辑设置”,我想读取用户输入的设置。
这里有一张图片:
我有 3 个解决方案的想法:
第一个想法:我在脚本中寻找一种方法来“假”点击链接。但我还没有找到一个函数...我尝试了 .click() 和 .trigger('click') 但这不起作用...对此有什么想法吗?
第二个想法:如果没有办法“伪造”该点击,我尝试简单地使用 window.location.href = "http://www.facebook.com/ajax/settings/privacy/connect.php";但这只是引导我进入 facebook-startpage。
最后的想法:用ajax发出请求。我使用 FireBug 来获取参数。在我的内容脚本中,我使用了 jQuery:
var data = '__a=1&__d=1&__user=100002895945078';
$.ajax({
type:"GET",
url:"http://www.facebook.com/ajax/settings/privacy/connect.php",
data: data,
success: function(response) {
alert(response);
},
error: function(xhr) {
alert('Error! Status = ' + xhr.status);
}
});
我使用了 FireBug,发现请求与单击“编辑设置”链接时的请求相同。甚至响应也是相同的(您可以在这里看到它:http://pastie.org/private/gk7fnfkretolkqd8xlmqhw) 我需要的信息包含在此回复中,但我不知道如何获取它。
我收到错误警报:"Error! Status = 200"
,但通常 200 就可以了!? 对话框没有弹出,DOM 节点也没有添加。 我必须自己做吗?
I want to develop an firefox-extension using javascript&jQuery which extrats the facebook-privacy settings of a user.
At the "privacy settings" menue you can click at "Edit settings" and i want to read the settings the user entered.
Here a picture:
I had 3 ideas for a solution:
First idea: I looked for a way in my script to "fake" the clicking on the link. But I haven't found a function... I tried .click() and .trigger('click') but that doesn't work... any idea for this?
Second idea: If there is no way to "fake" that click, i tried to simply open that link with window.location.href = "http://www.facebook.com/ajax/settings/privacy/connect.php"; but that just lead me to the facebook-startpage.
last idea: make a request with ajax. I used FireBug to get to the parameter. In my content-script I used jQuery:
var data = '__a=1&__d=1&__user=100002895945078';
$.ajax({
type:"GET",
url:"http://www.facebook.com/ajax/settings/privacy/connect.php",
data: data,
success: function(response) {
alert(response);
},
error: function(xhr) {
alert('Error! Status = ' + xhr.status);
}
});
I used FireBug and found out that the Request is the same as if i click on the "Edit settings"-link. Even the Response is the same (you can see it here: http://pastie.org/private/gk7fnfkretolkqd8xlmqhw)
The information I need are included at this Response, but I don't know how to get to it.
I get from the Error-alert: "Error! Status = 200"
, but normally 200 is ok!?
The Dialog isn't popping up and the DOM node isn't added.
Do I have to do this myself?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我得到了它。问题是我忘记将数据类型设置为文本。
I got it. The problem was that I forget to set the DataType to text.