This is on a job listing site and it has a Linkedin apply button plugin - this provides for a callback the someone has applied for a job. I've written the callback function which extracts the Job ID (a primary key in my database) and makes an AJX call to indcate that this Job ID has been applied for.

The Linkedin plugin is described here.

It essentially passes this JSON object to the callback:

      "jobTitle":"Chief Cat Herder"

This is the code placed within the head of the page:

<script type="text/javascript">
function linkedInApplySuccess(jsonReturnObj) 
    // no need to use any jquery json functions as already jabe a json object from linkedin (instead os a string)
    // see second answer here http://stackoverflow.com/questions/3569416/parsing-json-string-with-jquery-parsejson

    var job_id = jsonReturnObj.job.jobId;

        url: "/php/cv_db/ajax_log_linkedin_application.php",
        data: {job_id: job_id},
        type: "POST"


Regarding the AJAX, I am not looking for any return data and nor do I care about success or failure as should it fail. I'm not going to ask someone to apply for the job again. I do have error logging in my PHP file, though.


1 Answer 1


This looks pretty good, not much room for improvement I think. LinkedIn's JavaScript is calling linkedInApplySuccess, correct? All you have to do is specify data-success-callback, or something similar, in your HTML?

The only minor thing I would do is instead of sending just the job ID, send the entire JSON object. As long as resources aren't an issue, it's always best to capture all data and disregard the stuff you don't use rather than only collect the stuff you're currently using; this is because requirements change, and in the future you may want to do something with the data you've been ignoring. For instance, you may want to calculate how many people are applying for jobs with the position "Chief Weasel Wrangler".

You can alter your code to something like this:

$.post("/php/cv_db/ajax_log_linkedin_application.php", {application: jsonReturnObj});

(application refers to "job application" not "computer application" – maybe too ambiguous)

  • \$\begingroup\$ Hi, many thanks. Yes, the callback function is specified in the HTML you use to create the Linkedin button. I actually do only need the job id, as all the other information was in fact passed to the button (and then back to me on the json response) so the "Chief Weasel Wrangler" etc is in the database and accessed via the jobid. But I will play with your suggested code as a learning exercise. Thanks! \$\endgroup\$
    – user602088
    May 16, 2013 at 17:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.