linkedin应用按钮回调和jquery(或ext回调一般) [英] linkedin apply button callback and jquery (or ext callbacks in general)

查看:197
本文介绍了linkedin应用按钮回调和jquery(或ext回调一般)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网站中添加了linkedin apply按钮,将使用回调来跟踪应用程序。

I'm adding the linkedin apply button to a site and will use the callback to track applications

https://developer.linkedin.com/apply-processing-applications

Linkedin docs / example:

Linkedin docs/example:

<script type="text/javascript">
function myOnclickFunction(r) {
        alert("click");
        console.log(r);
        // do something here
}

function myOnsucesssFunction(r) {
        alert("success");
        console.log(r);
        // do something else here
}
</script>

<script type="IN/Apply" 
      data-email="apply-test@linkedin.com" 
      data-companyId="1337" 
      data-jobTitle="Chief Cat Herder" 
      data-onclick="myOnclickFunction"
      data-onsuccess="myOnsuccessFunction">
</script>

我可以用传统的javascript来做到这一点,但是想尝试这个作为我的第一个jquery项目,但不知道如何开始。

I'm able to do this with conventional javascript, but would like to try this as my first jquery project, but have no idea how to start.

有人可以给我一个开始,我可以从这里开始(只是给一个大纲 - 不要期待它写为我!)

Could someone give me a start on how I can go from here (just give an outline - not expecting to have it written for me!)

$(document).ready(function() {
   // do stuff when DOM is ready
 });

可以在其中添加一个函数,linkedin可以调用,甚至链接到类似的示例,我用关键字callback搜索似乎引用其他jquery函数生成的回调。

to adding a function within there that linkedin can call, or even a link to similar examples, as all my searching with the keyword callback seem to reference callbacks generated by other jquery functions.

我需要提取一些json数据,并做一个ajax调用。
谢谢,Kevin

I will need to extract some json data, and do an ajax call. Thanks, Kevin

推荐答案

不,如果你把东西放在 $ .ready()它放在一个匿名函数中并且在全局范围之外。

No, if you put something inside of $(document).ready() it is placed in an anonymous function and is outside of the global scope.

将在全局范围中调用的函数。因为它不是在加载时被调用,它不需要在 $(document).ready()内。

With something like that, you should probably put the function that is going to be called in the global scope. Since it isn't getting called on load anyway, it doesn't need to be inside $(document).ready().

此外,小心 $(document).ready(),如果不正确使用会减慢页面加载速度!

Also, be careful with $(document).ready(), if not used properly it can slow down the page load!

祝你好运jQuery,唯一的缺点是你会上瘾!

Good luck with jQuery, the only downside is that you'll get addicted!

这篇关于linkedin应用按钮回调和jquery(或ext回调一般)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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