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:
<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="[email protected]"
data-companyId="1337"
data-jobTitle="Chief Cat Herder"
data-onclick="myOnclickFunction"
data-onsuccess="myOnsuccessFunction">
</script>
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
});
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.
I will need to extract some json data, and do an ajax call. Thanks, Kevin
No, if you put something inside of $(document).ready()
it is placed in an anonymous function and is outside of the global scope.
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()
.
Also, be careful with $(document).ready()
, if not used properly it can slow down the page load!
Good luck with jQuery, the only downside is that you'll get addicted!