http://localhost/project1/index.php
//AJAX region
$(function(){
$.ajax({
type : 'GET',
url : 'https://jsonplaceholder.typicode.com/posts/1',
success : function(data){
console.log('success \n', data);
},
error : function(data){
console.log('error', data);
}
});
});//AJAX region
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
it's easily loading data from http://localhost/project1/json.php
console:

data is string, if I use $.parseJSON(data) or JSON.parse(data) i get following error...

I want data as realtime JSON object, so that I can access each properties & values.
json.phpreturns invalid JSON, how are you generating it? You should simply usejson_encodePHP function and if you want to do it right before echoing it set the header to JSON withheader('Content-type: application/json');.", for example