Unable to retrieve data from database jquery json



Database table image

I am trying to retrieve data stored in the database table using ajax. But to check if I am retrieving the data before I can list them on my page, I decided to use console.log first. However, I am getting "undefined" instead of the data.

I want to be able to retrieve the data from the database table and it seems like I am not pulling the data at all since console.log either shows nothing or undefined. I have also defined the variables at the top of the function.

$("#btnpost1").bind("click", function() {
// Call the post function

function loadpost() {
if ($("#NewPostForm").valid()) {

var url = serverURL() + "/load.php";

var JSONObject = {};

url: url,
type: 'GET',
data: JSONObject,
dataType: 'json',
contentType: "application/json; charset=utf-8",
success: function(arr) {
error: function() {


function _getloadResult(arr) {
for (var i = 0; i < arr.length; i++) {

jobtitle = arr.jobtitle;
startdate = arr.startdate;
enddate = arr.enddate;


<button type="submit" id="btnpost1" class="btnpost1">Post</button>

Continue reading...