JQuery/Ajax issue , callback response do not show data

Hi everyone, i'm a begginer in ELGG plugin developing, and i'm happy that there is a group for who needs help like me.

GOAL: i want to extract some userpage data with a php page and send it to a "response" placed in a js/JQuery file, i need to use that data for my script.

Problem:

1) the script is executed but i 'm not able to extract and send needed data to my script;
2) if i use JSON encode/decode i have an[object, Object] in console.log
3) if i not use JSON the result in console.log is "  {"output":false,"status":-1,"system_messages":{"error":[],"success":[]}}  ".


Code:

this is my JQuery/Ajax script:

$(document).ready(function(){


$.ajax ({


url:"mypage.php",
dataType: "json",
success: function(response){

alert(response);
console.log("Response: " +response);

if(response){

//some code

} else{

echo"Some Message";

}

 

 

This is my php file , placed in the same directory:

<?php

$owner = elgg_get_page_owner_entity();

 

echo json_encode($owner['name']);

 

?>
 

 

Please i need help.  it's important that i can pass some variable , from PHP to my js file.

i hope in a resolutive answer.

Thanks a lot.

 

Arthy

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking