I am using Ajax for Bootstrap Modal that pulling content from Database. I have a function in my functions file that check if a remote file exists:
function checkRemoteFile($url) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    // don't download content
    curl_setopt($ch, CURLOPT_NOBODY, 1);
    curl_setopt($ch, CURLOPT_FAILONERROR, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    if (curl_exec($ch) !== FALSE) {
        return true;
    } else {
        return false;
    }
}
I am trying to call the above function inside my ajax which is this:
$(document).on('click', '.show-detail', function (e) {
      e.preventDefault();
      $('#dynamic-content').html('');
      $('#modal-loader').show();
      $('#view-modal').modal();
      $.ajax({
            url: '',
            type: 'post',
            data: {GetData: 1, EmployeeID: $(this).data('id')},
            dataType: 'json'
      }).done(function (abc) {
      var number = '';
      $.each(abc[0].Phone, function (i, item) {
            number += '<p><span class="icon_phone" data-toggle="tooltip" data-placement="left" title="Phone/Mobile" /></span> ' + item.Phone + '' + (item.Extension !== "" ? ' Ext#: ' + item.Extension : '') + '</p>';
      });
      var email = '';
      $.each(abc[0].Email, function (i, item) {
            email += '<p><span class="icon_mail" data-toggle="tooltip" data-placement="left" title="Phone/Mobile" /></span>  <a href="mailto:' + item.Email + '">' + item.Email + '</a></p>';
       });
      var pic ='';
      $.each(abc, function (i, item) {
      if (checkRemoteFile('http://http://url.com/img/' + item.pictureCode+'.jpg?code=xxxx')){
      pic += '<img src="http://http://url.com/img/'+ item.pictureCode+'.jpg?code=xxxx" width= "50px" height= "50px" />';
      } else {
      pic += '<img src="assets/img/avatars/unknown-user.png" width= "50px" height= "50px" />';
      }  
      });
      var temp = '<div class="row">\n\
                        <div class="col-md-6">\n\
                              <p> '+ pic + '\n\
                              <h4>' + abc[0].FullName + '</h4>\n\
                              ' + number + '\n\
                              ' + email + '\n\
                        </div>\n\
                  </div>';
      $('#dynamic-content').html(temp);
      $('#modal-loader').hide();
      }).fail(function () {
      $('#dynamic-content').html('<i class="glyphicon glyphicon-info-sign"></i> Something went wrong, Please try again...');
      $('#modal-loader').hide();
      });
});
I am trying to call the function using:
var pic ='';
$.each(abc, function (i, item) {
          if (checkRemoteFile('http://url.com/img/' + item.pictureCode+'.jpg?code=xxxx')){
 pic += '<img src="http://url.com/img/'+ item.pictureCode+'.jpg?code=xxxx" width= "50px" height= "50px" />';
  } else {
  pic += '<img src="assets/img/avatars/unknown-user.png" width= "50px" height= "50px" />';
  }  
  });
but its not working
 
     
     
    