<?php require_once 'CandidateDetails.php'; header('content-type: application/json; charset=utf-8'); header('Access-Control-Allow-Origin: *'); if (empty($_POST['candidateDetails']) || empty($_POST['scoreDetails'])) { echo json_encode(array()); return; } $candidate = new CandidateDetails(); $resp = array('candidateId' => $candidate->addDetails($_POST['candidateDetails'], $_POST['scoreDetails'])); echo json_encode($resp);
<?php require_once 'CandidateDetails.php'; require_once 'QuestionType.php'; $candidate = new CandidateDetails(); $type = new QuestionType(); $resp = array(); $resp['candidateList'] = $candidate->getAllCandidates(); $resp['questionTypes'] = $type->getAllQuestionTypes(); $resp = json_encode($resp); echo $_REQUEST['callback'] . '(' . $resp . ')';