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:
<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;
$.ajax({
url: "/php/cv_db/ajax_log_linkedin_application.php",
data: {job_id: job_id},
type: "POST"
});
};
</script>
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.