Callback for job applicant 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:

{
   "event":"success",
   "job":{
      "companyID":"12345",
      "jobID":"9876",
      "jobTitle":"Chief Cat Herder"
   }
}


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

&lt;script type="text/javascript"&gt;
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;

    $.ajax({
        url: "/php/cv_db/ajax_log_linkedin_application.php",
        data: {job_id: job_id},
        type: "POST"
        });

    };
&lt;/script&gt;


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.
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)